# install.packages("INLA",repos=c(getOption("repos"),INLA="https://inla.r-inla-download.org/R/stable"), dep=TRUE)
tictoc::tic()
library(INLA) # For fitting integrated nested Laplace approximation (INLA) models
library(tidyverse) # For data manipulation and visualization
library(sp) # For spatial data handling
library(spdep) # For spatial dependence analysis
library(flextable) # For creating flexible tables
library(RColorBrewer) # For color palettes
library(rcartocolor) # For additional color palettes
library(cowplot) # For combining plots
library(janitor) # For cleaning data
library(broom)
# Functions ---------------------------------------------------------------
# Standardize a numeric vector
my_std <- function(x) { (x - mean(x,na.rm=TRUE)) / sd(x,na.rm = TRUE)}
# Fit a BYM2 model using INLA
fit_bym2 <- function(table,
outcome_var,
interest_var,
distribution = "poisson",
formula_terms = NULL,
prec_param = c(1, 0.001),
phi_param = c(0.5, 0.5)) {
# Define priors for precision and phi
prior <- list(
prec = list(
prior = "pc.prec",
param = prec_param),
phi = list(
prior = "pc",
param = phi_param)
)
# Construct the INLA formula based on input parameters
if (is.null(formula_terms)) {
inla_formula <- as.formula(paste(outcome_var, "~", interest_var, "+ f(ui, model = 'bym2', graph = g, hyper = prior, adjust.for.con.comp = TRUE,
constr = TRUE, scale.model = TRUE)"))
} else {
inla_formula <- as.formula(paste(outcome_var, "~", interest_var, "+", formula_terms, "+ f(ui, model = 'bym2', graph = g, hyper = prior, adjust.for.con.comp = TRUE,
constr = TRUE, scale.model = TRUE)"))
}
#adjust.for.con.comp = TRUE, scale.model = TRUE: assigns one intercept to each region in addition to using a sum-to-zero constraint for each connected region. By adding an intercept for each region, we infer that the baseline prevalence is different in the disconnected regions.
#The spatial random effects can be interpreted as the area-specific deviation from the region-specific risk in this case. The intercepts for the disconnected regions need to be explicitly specified in INLA:
# Fit the INLA model with BYM2 prior
fit <- inla(inla_formula,
data = table,
family = distribution,
control.compute = list(dic = TRUE, waic = TRUE,cpo=TRUE,config=TRUE),
control.predictor = list(compute = TRUE),
verbose = FALSE)
# Return the INLA model object
return(fit)
}
# Tidy up INLA model fixed effects results
tidy_inla <- function(fixed_effects, exponentiate = FALSE, sigfig =NULL) {
# Create a tidy data frame
tidy_results <- fixed_effects %>%
dplyr::rename(estimate = 'mean',
std.error = 'sd',
lower_ci = '0.025quant',
upper_ci = '0.975quant')
if (exponentiate) {
tidy_results <- tidy_results %>%
mutate(estimate = exp(estimate),
lower_ci = exp(lower_ci),
upper_ci = exp(upper_ci))
}
if (!is.null(sigfig)) {
tidy_results <- tidy_results %>%
mutate(estimate = signif(estimate, sigfig),
std.error = signif(std.error, sigfig),
lower_ci = signif(lower_ci, sigfig),
upper_ci = signif(upper_ci, sigfig))
}
return(tidy_results)
}
# prs <- function(x,n.dig = 2){
#
# formatC(round(x,n.dig), format='f', big.mark = ",",digits = n.dig)
#
# }
cma_models <- function(cma_data,
cma_name,
outcome,
deprivation_indicator,
distribution = "poisson") {
### 0: Unadjusted non=spatial
print("Fit unadjusted non-spatial")
m0 <- inla(
as.formula(paste(
outcome, "~", deprivation_indicator, "+ f(ui, model = 'iid')"
)),
data = cma_data,
family = distribution,
control.compute = list(
dic = TRUE,
waic = TRUE,
cpo = TRUE,
config = TRUE
),
control.predictor = list(compute = TRUE),
verbose = FALSE
)
m0_fe <- tidy_inla(m0$summary.fixed,
exponentiate = TRUE,
sigfig = 3) %>%
mutate(
`IRR (95% CI)` = paste0(estimate, " (", lower_ci, ", ", upper_ci, ")"),
variable = row.names(.)
) %>%
select(variable, `IRR (95% CI)`)
###### Spatial Models #####
### 1: Unadjusted
print("Fit unadjusted")
m1 <- fit_bym2(cma_data, outcome, deprivation_indicator, distribution)
m1_fe <- tidy_inla(m1$summary.fixed,
exponentiate = TRUE,
sigfig = 3) %>%
mutate(
`IRR (95% CI)` = paste0(estimate, " (", lower_ci, ", ", upper_ci, ")"),
variable = row.names(.)
) %>%
select(variable, `IRR (95% CI)`)
print("Fit adjusted by road length")
### 2: Adjusted by Road Length
m2 <- fit_bym2(cma_data,
outcome,
deprivation_indicator,
formula_terms = "ln_roads_km_c",
distribution)
m2_fe <- tidy_inla(m2$summary.fixed,
exponentiate = TRUE,
sigfig = 3) %>%
mutate(
`IRR (95% CI)` = paste0(estimate, " (", lower_ci, ", ", upper_ci, ")"),
variable = row.names(.)
) %>%
select(variable, `IRR (95% CI)`)
### 3: Adjusted by Road Length and other variables
m3 <- fit_bym2(cma_data,
outcome,
deprivation_indicator,
formula_terms = "ln_roads_km_c + roads_prop_highway_arterial_z + ale_index_z + canbics_index_z + population_100_c",
distribution)
m3_fe <- tidy_inla(m3$summary.fixed,
exponentiate = TRUE,
sigfig = 3) %>%
mutate(
`IRR (95% CI)` = paste0(estimate, " (", lower_ci, ", ", upper_ci, ")"),
variable = row.names(.)
) %>%
select(variable, `IRR (95% CI)`)
l <- list(m0, m1, m2, m3)
names(l) <- c("Nonspatial","Unadjusted", "Adjusted1", "Adjusted2")
print("Fit adjusted by road length and covariates")
# Compile results into a tibble
tibble(
cma = cma_name,
model_type = c("Nonspatial","unadjusted", "adjusted_minimal", "adjusted_full"),
models = l,
fixed_effects = list(m0_fe, m1_fe, m2_fe, m3_fe)
)
}
# Clean and format fixed effects results from models
clean_fixed_effects <- function(cma_model_object){
cma_model_object %>%
bind_rows(,.id="model_type") %>%
mutate(model_type = case_when(model_type == "1"~"Nonspatial Unadjusted IRR (95% CI)",
model_type == "2"~"Spatial Unadjusted IRR (95% CI)",
model_type == "3"~"Spatial Minimally Adjusted IRR (95% CI)",
model_type == "4"~"Spatial Adjusted IRR (95% CI)"
)) %>%
pivot_wider(id_cols = variable,names_from = model_type,values_from = `IRR (95% CI)` ) %>%
mutate(variable = case_when(variable == "ln_roads_km_c" ~"Log(Total KMs of Road)",
variable == "roads_prop_highway_arterial_z" ~ "% of roads classifed as Arterial/Highway (SD)",
variable == "ale_index_z" ~ "Canadian Active Living Enrivonment Index (SD)",
variable == "canbics_index_z" ~ "Canadian Bikeway Safety and Comfort Index (SD)",
variable == "population_100_c" ~ "Population (100)",
TRUE ~ variable
))
}
assign_nearest_neighbors <- function(nb_object, sp_object,make_symmetrical=TRUE) {
# Calculate centroids for isolated polygons
centroids <- coordinates(sp_object) # If using sp
centroids_nn <- knearneigh(centroids, k = 3)
# Get the list of neighbors
zero_nb_logical <- sapply(nb_object, function(x) x[1] ==0)
zero_nb_indices <- which(zero_nb_logical)
zero_nn <- centroids_nn$nn[zero_nb_indices, ]
for(i in 1:length(zero_nn)){
nb_object[zero_nb_indices[i]] <- zero_nn[i]
}
if(make_symmetrical==TRUE){
nb_object <- make.sym.nb(nb_object)
}
return(nb_object)
}
create_descriptive_table <- function(sf_obj, selected_vars) {
sf_obj %>%
# Drop geometry and select only the specified variables
st_drop_geometry() %>%
select(all_of(selected_vars)) %>%
# Gather descriptive statistics for each variable
summarise(across(everything(), list(
sum = ~sum(.x, na.rm = TRUE),
mean = ~mean(.x, na.rm = TRUE),
sd = ~sd(.x, na.rm = TRUE),
min = ~min(.x, na.rm = TRUE),
max = ~max(.x, na.rm = TRUE),
n = ~sum(!is.na(.x)|is.na(.x)), # Count non-NA values
missing = ~sum(is.na(.x)),
n_zero = ~sum(.x==0,na.rm=TRUE)# Count 0 values
), .names = "{.col}-{.fn}")) %>%
# Pivot longer to have each variable as its own row
pivot_longer(everything(),
names_to = c("variable", ".value"),
names_sep = "-") %>%
# Add a column to identify the sf object
# Reorder columns for better readability
select(variable, n, sum, mean, sd, min, max, , missing,n_zero)
}
# Load and clean census data for Canadian metropolitan areas (CMA)
cma_name <- cancensus::get_census("CA21",
level = "CMA",
regions = list(PR=59)) %>%
rename(CMA_UID = GeoUID, # Rename GeoUID to CMA_UID for clarity
`CMA Name` = `Region Name`, # Rename 'Region Name' to 'CMA Name'
cma_population = Population) %>% # Rename 'Population' to 'cma_population'
arrange(desc(cma_population)) %>% # Sort by population in descending order
select(CMA_UID, Type, `CMA Name`, cma_population) %>% # Select relevant columns
mutate(`CMA Name` = str_remove_all(`CMA Name`, " \\(B\\)|\\(K\\)|\\(D\\)")) %>% # Remove labels (B, K, D) from names
clean_names() %>% # Clean column names (lowercase and snake_case)
mutate(cma_name = stringr::str_trim(cma_name, "right")) # Trim whitespace from the right
## Downloading: 920 B Downloading: 920 B Downloading: 920 B Downloading: 920 B Downloading: 920 B Downloading: 920 B
# Read spatial data for dissemination areas in British Columbia
bc_da <- st_read(
"C:/Users/micha/Documents/GitHub/Area-Level-Deprivation-Traffic-Injury/Processed Data/da_v3_2021.gpkg"
) %>%
# Join the census data with the spatial data
left_join(cma_name, by = join_by(cma_uid)) %>%
filter(!is.na(cma_name)) %>% # Filter out rows without CMA names
mutate(
population_100 = population / 100, # Scale population down by 100
population_100_c = scale(population_100, scale = FALSE), # Center population
total_roads_km = total_roads_m / 1000, # Convert road lengths from meters to kilometers
# Calculate casualty claims rates per kilometer of road
n_casualty_claims_rate = n_casualty_claims / total_roads_km * 10,
n_pedestrian_casualty_claims_rate = n_pedestrian_casualty_claims / total_roads_km * 10,
n_cyclist_casualty_claims_rate = n_cyclist_casualty_claims / total_roads_km * 10,
# Calculate the proportion of roads that are highways or arterials
roads_prop_highway_arterial = (highway_m + arterial_m) / total_roads_m,
roads_prop_highway_arterial_z = my_std(roads_prop_highway_arterial), # Standardize the proportion
# Log-transform the total length of roads in kilometers
ln_roads_km = ifelse(total_roads_km == 0, NA, log(total_roads_km)),
ln_roads_km_c = scale(ln_roads_km, scale = FALSE), # Center log-transformed roads
# Calculate casualty claims rates by total road kilometers
casualty_claims_rate = n_casualty_claims / total_roads_km * 10,
cyclist_casualty_claims_rate = n_cyclist_casualty_claims / total_roads_km * 10,
pedestrian_casualty_claims_rate = n_pedestrian_casualty_claims / total_roads_km * 10,
# Convert CANBICS class to descriptive categories
canbics_class_c = case_when(
canbics_class == 1 | canbics_class == "2" ~ "1 - Low",
canbics_class == 5 | canbics_class == "4" ~ "3 - High",
canbics_class == 3 ~ "2 - Medium"
),
canbics_index_z = my_std(canbics_index), # Standardize CANBICS index
# Convert ALE class to descriptive categories
ale_class_c = case_when(
ale_class == 1 | ale_class == "2" ~ "1 - Low",
ale_class == 5 | ale_class == "4" ~ "3 - High",
ale_class == 3 ~ "2 - Medium"
),
ale_index_z = my_std(ale_index), # Standardize ALE index
# Calculate VanDIX score based on various factors
z_no_highschool_prevalance_w = scale(no_highschool_prevalance),
z_university_degree_prevalance_w = scale(university_degree_prevalance * -1),
z_unemployment_rate_w = scale(unemployment_rate),
z_lone_parent_fam_prevalence_w = scale(lone_parent_fam_prevalence),
z_hh_avg_income_w = scale(hh_avg_income * -1),
z_home_owner_prevalence_w = scale(home_owner_prevalence * -1),
z_participation_rate_w = scale(participation_rate * -1),
# Compute VanDIX (Area Level Deprivation Index) score
vandix = as.numeric(
z_hh_avg_income_w * 0.089 +
z_home_owner_prevalence_w * 0.089 +
z_lone_parent_fam_prevalence_w * 0.143 +
z_no_highschool_prevalance_w * 0.25 +
z_university_degree_prevalance_w * 0.179 +
z_unemployment_rate_w * 0.214 +
z_participation_rate_w * 0.036
),
vandix_z = my_std(vandix),
# Categorize the standardized VanDIX score
vandix_z_c = case_when(
vandix_z < -5 ~ "<-5",
vandix_z >= -5 & vandix_z < -4 ~ "-5 - -4",
vandix_z >= -4 & vandix_z < -3 ~ "-4 - -3",
vandix_z >= -3 & vandix_z < -2 ~ "-3 - -2",
vandix_z >= -2 & vandix_z < -1 ~ "-2 - -1",
vandix_z >= -1 & vandix_z < 0 ~ "-1 - 0",
vandix_z >= 0 & vandix_z < 1 ~ "0 - 1",
vandix_z >= 1 & vandix_z < 2 ~ "1 - 2",
vandix_z >= 2 & vandix_z < 3 ~ "2 - 3",
vandix_z >= 3 & vandix_z < 4 ~ "3 - 4",
vandix_z >= 4 & vandix_z < 5 ~ "4 - 5",
vandix_z >= 5 ~ ">5"
),
# Convert the VanDIX categories into a factor for ordered plotting
vandix_z_c = factor(vandix_z_c, levels = c("<-5", "-5 - -4", "-4 - -3", "-3 - -2", "-2 - -1", "-1 - 0", "0 - 1", "1 - 2", "2 - 3", "3 - 4", "4 - 5", ">5"))
) %>%
# Assign regions based on CMA names
mutate(region_name = case_when(
cma_name %in% c("Prince Rupert", "Terrace") ~ "Northwest",
cma_name %in% c("Fort St. John", "Dawson Creek", "Prince George", "Quesnel", "Williams Lake") ~ "North Central",
cma_name %in% c("Kamloops", "Salmon Arm") ~ "Kamloops-Salmon Arm",
cma_name %in% c("Vernon", "Kelowna", "Penticton") ~ "Okanagan",
cma_name %in% c("Cranbrook", "Nelson", "Trail") ~ "Southeast",
cma_name %in% c("Vancouver", "Squamish") ~ "Vancouver-Squamish",
cma_name %in% c("Abbotsford - Mission", "Chilliwack") ~ "Fraser Valley",
cma_name %in% c("Campbell River", "Courtenay", "Port Alberni", "Parksville", "Nanaimo", "Ladysmith", "Duncan", "Powell River") ~ "Central Island-Powell River",
cma_name == "Victoria" ~ "Victoria",
TRUE ~ NA_character_ # Handle cases where CMA name doesn't match any of the specified values
))
## Reading layer `da_v3_2021' from data source
## `C:\Users\micha\Documents\GitHub\Area-Level-Deprivation-Traffic-Injury\Processed Data\da_v3_2021.gpkg'
## using driver `GPKG'
## Simple feature collection with 7848 features and 130 fields
## Geometry type: MULTIPOLYGON
## Dimension: XY
## Bounding box: xmin: 273876.1 ymin: 367780.7 xmax: 1870608 ymax: 1735671
## Projected CRS: NAD83 / BC Albers
# bc_da %>%
# filter(total_roads_km==0) %>%
# nrow()
bc_da <- bc_da %>%
filter(total_roads_km>0) #filter out DAs without any roads
# Split the data into a list of CMAs
bc_cma <- bc_da %>%
split(.$cma_name)
# Split the data into a list of regions
bc_region <- bc_da %>%
split(.$region_name)
# Summarize population data for each CMA
cma_pop <- bc_da %>%
st_drop_geometry() %>% # Remove geometry for summarization
group_by(cma_name) %>%
summarise(n_da = n(), # Count the number of dissemination areas
population = sum(population, na.rm = TRUE)) %>%
arrange(desc(population)) # Sort by population
# Summarize population data for each region
region_pop <- bc_da %>%
st_drop_geometry() %>% # Remove geometry for summarization
group_by(region_name) %>%
summarise(n_da = n(), # Count the number of dissemination areas
population = sum(population, na.rm = TRUE)) %>%
arrange(desc(population)) # Sort by population
# Create descriptive tables for each region
region_descriptives <- map(
bc_region,
create_descriptive_table,
c(
"n_claims",
"n_casualty_claims",
"n_cyclist_claims",
"n_cyclist_casualty_claims",
"n_pedestrian_claims",
"n_pedestrian_casualty_claims",
"population",
"total_roads_km",
"roads_prop_highway_arterial",
"no_highschool_prevalance",
"unemployment_rate",
"hh_avg_income",
"participation_rate",
"university_degree_prevalance",
"lone_parent_fam_prevalence",
"home_owner_prevalence",
"vandix",
"roads_prop_highway_arterial",
"ale_index",
"canbics_index"
)
) %>%
bind_rows(.id = "region") %>%
arrange(desc(n)) %>% # Sort by count
mutate(p_zero = n_zero / n * 100) # Calculate percentage of zero claims
# Create descriptive tables for each CMA
cma_descriptives <- map(
bc_cma,
create_descriptive_table,
c(
"n_claims",
"n_casualty_claims",
"n_cyclist_claims",
"n_cyclist_casualty_claims",
"n_pedestrian_claims",
"n_pedestrian_casualty_claims",
"population",
"total_roads_km",
"roads_prop_highway_arterial",
"no_highschool_prevalance",
"unemployment_rate",
"hh_avg_income",
"participation_rate",
"university_degree_prevalance",
"lone_parent_fam_prevalence",
"home_owner_prevalence",
"vandix",
"roads_prop_highway_arterial",
"ale_index",
"canbics_index"
)
) %>%
bind_rows(.id = "cma") %>%
arrange(desc(n)) %>% # Sort by count
mutate(p_zero = n_zero / n * 100) # Calculate percentage of zero claims
missing_data <- bc_da %>%
filter(is.na(vandix_z)|is.na(canbics_index_z)|is.na(ale_index_z)|total_roads_km==0|is.na(population))
nrow(missing_data)
## [1] 820
nrow(missing_data)/nrow(bc_da)
## [1] 0.1266801
create_descriptive_table(missing_data,
c(
"n_claims",
"n_casualty_claims",
"n_cyclist_claims",
"n_cyclist_casualty_claims",
"n_pedestrian_claims",
"n_pedestrian_casualty_claims",
"population",
"total_roads_km",
"roads_prop_highway_arterial",
"no_highschool_prevalance",
"unemployment_rate",
"hh_avg_income",
"participation_rate",
"university_degree_prevalance",
"lone_parent_fam_prevalence",
"home_owner_prevalence",
"roads_prop_highway_arterial",
"vandix_z",
"ale_index_z",
"canbics_index_z"
)) %>%
mutate(
complete = n- missing,
p_missing = missing/n*100,
) %>%
select(variable,n,complete,missing,p_missing,everything()) %>%
flextable() %>%
merge_v(j = ~ + n ) %>%
theme_booktabs() %>%
colformat_double(
big.mark = ",", digits = 1, na_str = "N/A"
)
variable | n | complete | missing | p_missing | sum | mean | sd | min | max | n_zero |
|---|---|---|---|---|---|---|---|---|---|---|
n_claims | 820 | 820 | 0 | 0.0 | 123,572.0 | 150.7 | 301.5 | 0.0 | 3,234.0 | 49 |
n_casualty_claims | 820 | 0 | 0.0 | 24,831.0 | 30.3 | 63.5 | 0.0 | 649.0 | 111 | |
n_cyclist_claims | 820 | 0 | 0.0 | 1,519.0 | 1.9 | 6.7 | 0.0 | 115.0 | 500 | |
n_cyclist_casualty_claims | 820 | 0 | 0.0 | 988.0 | 1.2 | 4.5 | 0.0 | 72.0 | 567 | |
n_pedestrian_claims | 820 | 0 | 0.0 | 1,657.0 | 2.0 | 5.3 | 0.0 | 56.0 | 454 | |
n_pedestrian_casualty_claims | 820 | 0 | 0.0 | 1,252.0 | 1.5 | 3.8 | 0.0 | 39.0 | 478 | |
population | 817 | 3 | 0.4 | 553,045.0 | 676.9 | 709.0 | 0.0 | 8,739.0 | 35 | |
total_roads_km | 820 | 0 | 0.0 | 9,193.1 | 11.2 | 25.3 | 0.0 | 286.0 | 0 | |
roads_prop_highway_arterial | 820 | 0 | 0.0 | 140.3 | 0.2 | 0.2 | 0.0 | 1.0 | 340 | |
no_highschool_prevalance | 234 | 586 | 71.5 | 48.9 | 0.2 | 0.1 | 0.0 | 0.8 | 10 | |
unemployment_rate | 234 | 586 | 71.5 | 2,269.4 | 9.7 | 9.8 | 0.0 | 60.0 | 57 | |
hh_avg_income | 105 | 715 | 87.2 | 8,304,484.0 | 79,090.3 | 22,810.6 | 38,632.0 | 158,248.0 | 0 | |
participation_rate | 234 | 586 | 71.5 | 14,203.2 | 60.7 | 14.7 | 0.0 | 94.6 | 1 | |
university_degree_prevalance | 234 | 586 | 71.5 | 116.2 | 0.5 | 0.1 | 0.0 | 0.8 | 1 | |
lone_parent_fam_prevalence | 236 | 584 | 71.2 | 41.9 | 0.2 | 0.2 | 0.0 | 1.0 | 19 | |
home_owner_prevalence | 234 | 586 | 71.5 | 173.5 | 0.7 | 0.3 | 0.0 | 1.3 | 9 | |
vandix_z | 103 | 717 | 87.4 | 8.6 | 0.1 | 0.9 | -1.6 | 3.2 | 0 | |
ale_index_z | 140 | 680 | 82.9 | -38.5 | -0.3 | 1.1 | -0.9 | 6.2 | 0 | |
canbics_index_z | 169 | 651 | 79.4 | -52.9 | -0.3 | 0.9 | -0.9 | 4.4 | 0 |
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Vancouver-Squamish | n_claims | 3,620 | 693,530.0 | 191.6 | 363.3 | 0.0 | 6,315.0 | 0 | 10 | 0.3 |
n_casualty_claims | 149,692.0 | 41.4 | 84.8 | 0.0 | 1,896.0 | 0 | 131 | 3.6 | ||
n_cyclist_claims | 7,656.0 | 2.1 | 4.7 | 0.0 | 115.0 | 0 | 1,455 | 40.2 | ||
n_cyclist_casualty_claims | 4,968.0 | 1.4 | 3.2 | 0.0 | 72.0 | 0 | 1,857 | 51.3 | ||
n_pedestrian_claims | 9,539.0 | 2.6 | 5.1 | 0.0 | 80.0 | 0 | 1,288 | 35.6 | ||
n_pedestrian_casualty_claims | 7,502.0 | 2.1 | 4.0 | 0.0 | 68.0 | 0 | 1,456 | 40.2 | ||
population | 2,667,057.0 | 737.0 | 532.2 | 0.0 | 8,800.0 | 1 | 8 | 0.2 | ||
total_roads_km | 15,056.8 | 4.2 | 5.8 | 0.0 | 176.7 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 577.0 | 0.2 | 0.2 | 0.0 | 1.0 | 0 | 1,426 | 39.4 | ||
no_highschool_prevalance | 476.5 | 0.1 | 0.1 | 0.0 | 0.8 | 298 | 16 | 0.4 | ||
unemployment_rate | 19,517.2 | 5.9 | 3.6 | 0.0 | 40.0 | 298 | 339 | 9.4 | ||
hh_avg_income | 279,328,113.0 | 85,421.4 | 34,171.3 | 0.0 | 560,267.0 | 350 | 3 | 0.1 | ||
participation_rate | 215,750.1 | 64.9 | 10.1 | 0.0 | 94.6 | 298 | 1 | 0.0 | ||
university_degree_prevalance | 1,890.5 | 0.6 | 0.1 | 0.1 | 1.0 | 298 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 513.7 | 0.2 | 0.1 | 0.0 | 0.7 | 297 | 15 | 0.4 | ||
home_owner_prevalence | 2,229.1 | 0.7 | 0.2 | 0.0 | 1.3 | 298 | 36 | 1.0 | ||
vandix | -473.2 | -0.1 | 0.6 | -2.1 | 3.9 | 350 | 0 | 0.0 | ||
ale_index | 5,407.4 | 1.6 | 3.6 | -2.1 | 25.1 | 308 | 13 | 0.4 | ||
canbics_index | 15,159.2 | 4.6 | 4.1 | 0.0 | 24.3 | 303 | 72 | 2.0 |
claims <- ggplot() +
geom_sf(data = vancouver_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = vancouver_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = vancouver_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
vancouver_sp <- as(vancouver_sf, "Spatial")
vancouver_sp$ui <- 1:nrow(vancouver_sp@data)
coords <- coordinates(vancouver_sp)
vancouver_nb <- poly2nb(vancouver_sp, queen = TRUE)
## Warning in poly2nb(vancouver_sp, queen = TRUE): neighbour object has 5 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
vancouver_nb
## Neighbour list object:
## Number of regions: 3620
## Number of nonzero links: 22970
## Percentage nonzero weights: 0.1752846
## Average number of links: 6.345304
## 5 disjoint connected subgraphs
#assign nearest neighbour for no links
vancouver_nb <- assign_nearest_neighbors(vancouver_nb,vancouver_sp)
plot(vancouver_sp, border = grey(0.5))
plot(vancouver_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(vancouver_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(vancouver_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: vancouver_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 24.44, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 2.317291e-01 -2.763194e-04 9.011585e-05
cyc_cc_mi <- moran.test(vancouver_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: vancouver_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 38.937, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 3.682520e-01 -2.763194e-04 8.957925e-05
pd_cc_mi <- moran.test(vancouver_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: vancouver_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 32.697, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 3.121578e-01 -2.763194e-04 9.130404e-05
nb2INLA("vancouver.adj", vancouver_nb)
g <- inla.read.graph(filename = "vancouver.adj")
# Model Set 1: Total Casualty Claim Crashes
van_models_1 <- cma_models(cma_data = vancouver_sp@data, cma_name = "Vancouver-Squamish",outcome = "n_casualty_claims", deprivation_indicator = "vandix_z",distribution = "poisson")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
van_all <- clean_fixed_effects(van_models_1$fixed_effects)
map(van_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.384, Running = 1.27, Post = 0.245, Total = 1.9
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.852 0.024 2.804 2.852 2.899 2.852 0
## vandix_z 0.407 0.027 0.354 0.407 0.460 0.407 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.536 0.014 0.508 0.536 0.564 0.535
##
## Deviance Information Criterion (DIC) ...............: 23972.24
## Deviance Information Criterion (DIC, saturated) ....: 7523.23
## Effective number of parameters .....................: 3482.99
##
## Watanabe-Akaike information criterion (WAIC) ...: 23973.60
## Effective number of parameters .................: 2395.12
##
## Marginal log-Likelihood: -16493.76
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 21.3, Running = 4.93, Post = 0.722, Total = 27
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.804 0.016 2.773 2.804 2.836 2.804 0
## vandix_z 0.204 0.033 0.139 0.204 0.269 0.204 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.311 0.014 0.285 0.311 0.340 0.311
## Phi for ui 0.793 0.021 0.749 0.794 0.832 0.795
##
## Deviance Information Criterion (DIC) ...............: 23815.04
## Deviance Information Criterion (DIC, saturated) ....: 7366.01
## Effective number of parameters .....................: 3418.92
##
## Watanabe-Akaike information criterion (WAIC) ...: 23708.89
## Effective number of parameters .................: 2287.15
##
## Marginal log-Likelihood: -15034.86
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 22, Running = 5.28, Post = 0.933, Total = 28.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 3.254 0.015 3.224 3.254 3.284 3.254 0
## vandix_z 0.315 0.026 0.264 0.315 0.366 0.315 0
## ln_roads_km_c 1.291 0.029 1.234 1.291 1.348 1.291 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.507 0.020 0.469 0.507 0.547 0.506
## Phi for ui 0.810 0.016 0.777 0.810 0.840 0.811
##
## Deviance Information Criterion (DIC) ...............: 23704.56
## Deviance Information Criterion (DIC, saturated) ....: 7255.51
## Effective number of parameters .....................: 3265.09
##
## Watanabe-Akaike information criterion (WAIC) ...: 23512.58
## Effective number of parameters .................: 2154.27
##
## Marginal log-Likelihood: -14247.28
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 22.6, Running = 5.48, Post = 0.845, Total = 28.9
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode
## (Intercept) 2.989 0.017 2.956 2.989 3.022 2.989
## vandix_z 0.216 0.022 0.174 0.216 0.258 0.216
## ln_roads_km_c 0.987 0.027 0.934 0.987 1.040 0.987
## roads_prop_highway_arterial_z 0.595 0.016 0.563 0.595 0.626 0.595
## ale_index_z 0.111 0.037 0.037 0.111 0.184 0.111
## canbics_index_z 0.210 0.037 0.137 0.209 0.282 0.209
## population_100_c 0.017 0.003 0.012 0.017 0.022 0.017
## kld
## (Intercept) 0
## vandix_z 0
## ln_roads_km_c 0
## roads_prop_highway_arterial_z 0
## ale_index_z 0
## canbics_index_z 0
## population_100_c 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.838 0.038 0.766 0.837 0.915 0.836
## Phi for ui 0.777 0.022 0.732 0.777 0.817 0.779
##
## Deviance Information Criterion (DIC) ...............: 23557.65
## Deviance Information Criterion (DIC, saturated) ....: 7108.60
## Effective number of parameters .....................: 3108.54
##
## Watanabe-Akaike information criterion (WAIC) ...: 23292.03
## Effective number of parameters .................: 2020.13
##
## Marginal log-Likelihood: -13604.82
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
van_models_2 <- cma_models(vancouver_sp@data,"Vancouver-Squamish","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
van_cyclist <- clean_fixed_effects(van_models_2$fixed_effects)
map(van_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.193, Running = 1.09, Post = 0.407, Total = 1.69
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.616 0.043 -0.704 -0.615 -0.534 -0.615 0
## vandix_z 0.028 0.032 -0.035 0.028 0.091 0.028 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.632 0.029 0.577 0.631 0.69 0.63
##
## Deviance Information Criterion (DIC) ...............: 10994.39
## Deviance Information Criterion (DIC, saturated) ....: 6440.89
## Effective number of parameters .....................: 2464.49
##
## Watanabe-Akaike information criterion (WAIC) ...: 12145.92
## Effective number of parameters .................: 2387.64
##
## Marginal log-Likelihood: -5594.29
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 21.4, Running = 4.24, Post = 0.538, Total = 26.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.522 0.032 -0.587 -0.522 -0.459 -0.522 0
## vandix_z 0.142 0.037 0.069 0.142 0.216 0.142 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.567 0.042 0.489 0.565 0.654 0.562
## Phi for ui 0.633 0.048 0.534 0.635 0.724 0.638
##
## Deviance Information Criterion (DIC) ...............: 9763.24
## Deviance Information Criterion (DIC, saturated) ....: 5209.46
## Effective number of parameters .....................: 1753.30
##
## Watanabe-Akaike information criterion (WAIC) ...: 9983.12
## Effective number of parameters .................: 1387.74
##
## Marginal log-Likelihood: -4165.30
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 21.4, Running = 4.87, Post = 0.472, Total = 26.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.134 0.026 -0.185 -0.134 -0.083 -0.134 0
## vandix_z 0.209 0.032 0.146 0.209 0.272 0.209 0
## ln_roads_km_c 1.071 0.035 1.002 1.071 1.140 1.071 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.621 0.047 0.532 0.620 0.715 0.619
## Phi for ui 0.934 0.025 0.876 0.938 0.974 0.945
##
## Deviance Information Criterion (DIC) ...............: 9035.59
## Deviance Information Criterion (DIC, saturated) ....: 4481.80
## Effective number of parameters .....................: 1133.21
##
## Watanabe-Akaike information criterion (WAIC) ...: 9017.56
## Effective number of parameters .................: 857.85
##
## Marginal log-Likelihood: -3787.50
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 20.8, Running = 5.16, Post = 0.744, Total = 26.7
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.291 0.031 -0.352 -0.291 -0.231
## vandix_z 0.180 0.032 0.118 0.180 0.243
## ln_roads_km_c 0.843 0.039 0.766 0.843 0.920
## roads_prop_highway_arterial_z 0.302 0.024 0.256 0.302 0.349
## ale_index_z 0.041 0.045 -0.047 0.041 0.130
## canbics_index_z 0.092 0.048 -0.001 0.092 0.185
## population_100_c 0.022 0.003 0.016 0.022 0.028
## mode kld
## (Intercept) -0.291 0
## vandix_z 0.180 0
## ln_roads_km_c 0.843 0
## roads_prop_highway_arterial_z 0.302 0
## ale_index_z 0.041 0
## canbics_index_z 0.092 0
## population_100_c 0.022 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.820 0.070 0.688 0.817 0.963 0.815
## Phi for ui 0.871 0.037 0.788 0.875 0.934 0.882
##
## Deviance Information Criterion (DIC) ...............: 8931.11
## Deviance Information Criterion (DIC, saturated) ....: 4377.32
## Effective number of parameters .....................: 1047.28
##
## Watanabe-Akaike information criterion (WAIC) ...: 8896.67
## Effective number of parameters .................: 790.31
##
## Marginal log-Likelihood: -3707.54
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
van_models_3 <- cma_models(vancouver_sp@data,"Vancouver-Squamish","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
van_pedestrian <- clean_fixed_effects(van_models_3$fixed_effects)
map(van_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.176, Running = 1.08, Post = 0.165, Total = 1.42
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.020 0.031 -0.082 -0.019 0.041 -0.019 0
## vandix_z 0.358 0.029 0.302 0.358 0.415 0.358 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.716 0.03 0.659 0.715 0.776 0.714
##
## Deviance Information Criterion (DIC) ...............: 12538.87
## Deviance Information Criterion (DIC, saturated) ....: 6593.34
## Effective number of parameters .....................: 2530.98
##
## Watanabe-Akaike information criterion (WAIC) ...: 13203.40
## Effective number of parameters .................: 2158.93
##
## Marginal log-Likelihood: -6752.38
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 21, Running = 4.35, Post = 0.458, Total = 25.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.034 0.027 -0.088 -0.034 0.019 -0.034 0
## vandix_z 0.249 0.036 0.178 0.249 0.320 0.249 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.493 0.035 0.428 0.492 0.564 0.49
## Phi for ui 0.666 0.044 0.576 0.667 0.748 0.67
##
## Deviance Information Criterion (DIC) ...............: 11937.29
## Deviance Information Criterion (DIC, saturated) ....: 5991.71
## Effective number of parameters .....................: 2207.79
##
## Watanabe-Akaike information criterion (WAIC) ...: 12268.59
## Effective number of parameters .................: 1753.57
##
## Marginal log-Likelihood: -5477.92
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 21.5, Running = 4.73, Post = 0.494, Total = 26.7
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 0.319 0.022 0.275 0.319 0.363 0.319 0
## vandix_z 0.289 0.032 0.227 0.289 0.352 0.289 0
## ln_roads_km_c 0.995 0.034 0.928 0.995 1.063 0.995 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.448 0.027 0.395 0.447 0.503 0.447
## Phi for ui 0.951 0.018 0.908 0.953 0.979 0.958
##
## Deviance Information Criterion (DIC) ...............: 11177.21
## Deviance Information Criterion (DIC, saturated) ....: 5231.62
## Effective number of parameters .....................: 1631.93
##
## Watanabe-Akaike information criterion (WAIC) ...: 11152.83
## Effective number of parameters .................: 1186.54
##
## Marginal log-Likelihood: -5146.55
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 22.3, Running = 5.15, Post = 0.561, Total = 28
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode
## (Intercept) 0.114 0.028 0.060 0.115 0.168 0.115
## vandix_z 0.257 0.031 0.197 0.256 0.317 0.256
## ln_roads_km_c 0.715 0.039 0.639 0.715 0.791 0.715
## roads_prop_highway_arterial_z 0.396 0.022 0.353 0.396 0.440 0.396
## ale_index_z 0.232 0.046 0.142 0.232 0.323 0.232
## canbics_index_z 0.041 0.047 -0.051 0.041 0.134 0.041
## population_100_c 0.027 0.003 0.021 0.027 0.034 0.027
## kld
## (Intercept) 0
## vandix_z 0
## ln_roads_km_c 0
## roads_prop_highway_arterial_z 0
## ale_index_z 0
## canbics_index_z 0
## population_100_c 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.707 0.058 0.598 0.706 0.827 0.704
## Phi for ui 0.853 0.039 0.767 0.856 0.918 0.863
##
## Deviance Information Criterion (DIC) ...............: 11048.29
## Deviance Information Criterion (DIC, saturated) ....: 5102.70
## Effective number of parameters .....................: 1481.64
##
## Watanabe-Akaike information criterion (WAIC) ...: 10986.37
## Effective number of parameters .................: 1070.35
##
## Marginal log-Likelihood: -4957.32
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
van_results <- bind_rows(van_all %>% mutate(Region = "Vancouver-Squamish",Outcome = "All Injury Claims"),
van_cyclist %>% mutate(Region = "Vancouver-Squamish",Outcome = "Cyclist Injury Claims"),
van_pedestrian %>% mutate(Region = "Vancouver-Squamish",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Victoria | n_claims | 579 | 67,182.0 | 116.0 | 176.2 | 0.0 | 1,665.0 | 0 | 1 | 0.2 |
n_casualty_claims | 12,338.0 | 21.3 | 34.3 | 0.0 | 305.0 | 0 | 24 | 4.1 | ||
n_cyclist_claims | 1,471.0 | 2.5 | 4.4 | 0.0 | 53.0 | 0 | 194 | 33.5 | ||
n_cyclist_casualty_claims | 1,027.0 | 1.8 | 3.2 | 0.0 | 33.0 | 0 | 251 | 43.4 | ||
n_pedestrian_claims | 896.0 | 1.5 | 3.4 | 0.0 | 49.0 | 0 | 280 | 48.4 | ||
n_pedestrian_casualty_claims | 715.0 | 1.2 | 2.5 | 0.0 | 37.0 | 0 | 302 | 52.2 | ||
population | 397,237.0 | 686.1 | 431.4 | 0.0 | 4,739.0 | 0 | 1 | 0.2 | ||
total_roads_km | 3,261.2 | 5.6 | 5.6 | 0.5 | 48.0 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 67.1 | 0.1 | 0.1 | 0.0 | 0.7 | 0 | 238 | 41.1 | ||
no_highschool_prevalance | 66.7 | 0.1 | 0.1 | 0.0 | 0.4 | 28 | 0 | 0.0 | ||
unemployment_rate | 3,099.4 | 5.6 | 3.9 | 0.0 | 30.0 | 28 | 78 | 13.5 | ||
hh_avg_income | 41,608,895.0 | 77,340.0 | 26,930.8 | 26,088.0 | 233,035.0 | 41 | 0 | 0.0 | ||
participation_rate | 35,068.6 | 63.6 | 11.1 | 18.6 | 92.7 | 28 | 0 | 0.0 | ||
university_degree_prevalance | 329.1 | 0.6 | 0.1 | 0.3 | 0.9 | 28 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 84.0 | 0.2 | 0.1 | 0.0 | 0.6 | 30 | 5 | 0.9 | ||
home_owner_prevalence | 360.4 | 0.7 | 0.2 | 0.0 | 1.0 | 28 | 3 | 0.5 | ||
vandix | -130.2 | -0.2 | 0.5 | -1.5 | 3.0 | 43 | 0 | 0.0 | ||
ale_index | 335.8 | 0.6 | 1.8 | -2.1 | 7.1 | 26 | 2 | 0.3 | ||
canbics_index | 1,170.3 | 2.1 | 1.7 | 0.0 | 8.2 | 26 | 69 | 11.9 |
claims <- ggplot() +
geom_sf(data = victoria_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = victoria_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = victoria_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
victoria_sp <- as(victoria_sf, "Spatial")
victoria_sp$ui <- 1:nrow(victoria_sp@data)
coords <- coordinates(victoria_sp)
victoria_nb <- poly2nb(victoria_sp, queen = TRUE)
victoria_nb
## Neighbour list object:
## Number of regions: 579
## Number of nonzero links: 3458
## Percentage nonzero weights: 1.031497
## Average number of links: 5.972366
#assign nearest neighbour for no links
# victoria_nb <- assign_nearest_neighbors(victoria_nb,victoria_sp)
plot(victoria_sp, border = grey(0.5))
plot(victoria_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(victoria_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(victoria_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: victoria_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 16.267, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.3909113982 -0.0017301038 0.0005825849
cyc_cc_mi <- moran.test(victoria_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: victoria_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 13.616, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.3250899021 -0.0017301038 0.0005761224
pd_cc_mi <- moran.test(victoria_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: victoria_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 15.398, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.3525248862 -0.0017301038 0.0005292953
nb2INLA("victoria.adj", victoria_nb)
g <- inla.read.graph(filename = "victoria.adj")
# Model Set 1: Total Casualty Claim Crashes
victoria_models_1 <- cma_models(victoria_sp@data, "Victoria", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
victoria_all <- clean_fixed_effects(victoria_models_1$fixed_effects)
map(victoria_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.231, Running = 0.357, Post = 0.0794, Total = 0.668
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.448 0.057 2.336 2.449 2.559 2.449 0
## vandix_z 0.464 0.067 0.334 0.464 0.595 0.464 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.698 0.049 0.607 0.697 0.798 0.694
##
## Deviance Information Criterion (DIC) ...............: 3529.60
## Deviance Information Criterion (DIC, saturated) ....: 1183.69
## Effective number of parameters .....................: 536.54
##
## Watanabe-Akaike information criterion (WAIC) ...: 3539.96
## Effective number of parameters .................: 376.57
##
## Marginal log-Likelihood: -2312.02
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.2, Running = 0.861, Post = 0.255, Total = 16.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.351 0.036 2.281 2.351 2.421 2.351 0
## vandix_z 0.191 0.065 0.064 0.191 0.320 0.191 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.472 0.053 0.373 0.47 0.582 0.469
## Phi for ui 0.861 0.058 0.727 0.87 0.950 0.887
##
## Deviance Information Criterion (DIC) ...............: 3472.56
## Deviance Information Criterion (DIC, saturated) ....: 1126.64
## Effective number of parameters .....................: 508.73
##
## Watanabe-Akaike information criterion (WAIC) ...: 3442.98
## Effective number of parameters .................: 334.63
##
## Marginal log-Likelihood: -1976.94
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.3, Running = 0.845, Post = 0.185, Total = 16.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.373 0.026 2.322 2.373 2.423 2.373 0
## vandix_z 0.315 0.053 0.212 0.315 0.419 0.315 0
## ln_roads_km_c 1.224 0.073 1.081 1.224 1.367 1.224 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.606 0.048 0.516 0.605 0.704 0.604
## Phi for ui 0.982 0.018 0.934 0.987 0.999 0.996
##
## Deviance Information Criterion (DIC) ...............: 3403.14
## Deviance Information Criterion (DIC, saturated) ....: 1057.23
## Effective number of parameters .....................: 465.40
##
## Watanabe-Akaike information criterion (WAIC) ...: 3336.34
## Effective number of parameters .................: 285.26
##
## Marginal log-Likelihood: -1866.21
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15.4, Running = 1.02, Post = 0.204, Total = 16.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode
## (Intercept) 2.535 0.046 2.444 2.535 2.624 2.535
## vandix_z 0.193 0.050 0.095 0.193 0.291 0.193
## ln_roads_km_c 0.992 0.080 0.835 0.992 1.150 0.992
## roads_prop_highway_arterial_z 0.468 0.049 0.373 0.468 0.564 0.468
## ale_index_z 0.433 0.167 0.105 0.433 0.761 0.433
## canbics_index_z 0.370 0.156 0.064 0.371 0.676 0.371
## population_100_c 0.014 0.009 -0.002 0.014 0.031 0.014
## kld
## (Intercept) 0
## vandix_z 0
## ln_roads_km_c 0
## roads_prop_highway_arterial_z 0
## ale_index_z 0
## canbics_index_z 0
## population_100_c 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.816 0.087 0.650 0.814 0.992 0.817
## Phi for ui 0.943 0.042 0.833 0.954 0.992 0.977
##
## Deviance Information Criterion (DIC) ...............: 3399.35
## Deviance Information Criterion (DIC, saturated) ....: 1053.43
## Effective number of parameters .....................: 452.83
##
## Watanabe-Akaike information criterion (WAIC) ...: 3339.90
## Effective number of parameters .................: 282.83
##
## Marginal log-Likelihood: -1837.06
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
victoria_models_2 <- cma_models(victoria_sp@data,"Victoria","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
victoria_cyclist <- clean_fixed_effects(victoria_models_2$fixed_effects)
map(victoria_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.202, Running = 0.325, Post = 0.085, Total = 0.613
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.089 0.081 -0.252 -0.087 0.065 -0.087 0
## vandix_z 0.283 0.082 0.123 0.283 0.445 0.283 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.719 0.079 0.577 0.715 0.884 0.707
##
## Deviance Information Criterion (DIC) ...............: 1844.26
## Deviance Information Criterion (DIC, saturated) ....: 959.95
## Effective number of parameters .....................: 347.61
##
## Watanabe-Akaike information criterion (WAIC) ...: 1886.31
## Effective number of parameters .................: 271.71
##
## Marginal log-Likelihood: -1041.17
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.5, Running = 0.839, Post = 0.178, Total = 16.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.132 0.070 -0.274 -0.131 0.003 -0.132 0
## vandix_z 0.142 0.086 -0.026 0.142 0.311 0.142 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.663 0.095 0.495 0.657 0.867 0.645
## Phi for ui 0.625 0.102 0.414 0.630 0.808 0.640
##
## Deviance Information Criterion (DIC) ...............: 1756.80
## Deviance Information Criterion (DIC, saturated) ....: 872.49
## Effective number of parameters .....................: 289.31
##
## Watanabe-Akaike information criterion (WAIC) ...: 1758.54
## Effective number of parameters .................: 211.38
##
## Marginal log-Likelihood: -738.92
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.4, Running = 0.847, Post = 0.158, Total = 16.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.133 0.065 -0.263 -0.133 -0.007 -0.133 0
## vandix_z 0.239 0.080 0.082 0.239 0.396 0.239 0
## ln_roads_km_c 1.091 0.115 0.866 1.091 1.318 1.091 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.635 0.094 0.465 0.630 0.835 0.622
## Phi for ui 0.901 0.064 0.740 0.916 0.983 0.950
##
## Deviance Information Criterion (DIC) ...............: 1693.82
## Deviance Information Criterion (DIC, saturated) ....: 809.50
## Effective number of parameters .....................: 240.25
##
## Watanabe-Akaike information criterion (WAIC) ...: 1685.78
## Effective number of parameters .................: 174.70
##
## Marginal log-Likelihood: -702.76
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15.7, Running = 0.999, Post = 0.226, Total = 17
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode
## (Intercept) 0.053 0.080 -0.106 0.054 0.207 0.054
## vandix_z 0.111 0.080 -0.046 0.111 0.269 0.111
## ln_roads_km_c 0.882 0.129 0.629 0.882 1.135 0.882
## roads_prop_highway_arterial_z 0.309 0.073 0.167 0.309 0.452 0.309
## ale_index_z 0.400 0.221 -0.033 0.400 0.835 0.400
## canbics_index_z 0.604 0.212 0.187 0.604 1.021 0.604
## population_100_c 0.030 0.014 0.004 0.030 0.057 0.030
## kld
## (Intercept) 0
## vandix_z 0
## ln_roads_km_c 0
## roads_prop_highway_arterial_z 0
## ale_index_z 0
## canbics_index_z 0
## population_100_c 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.845 0.140 0.598 0.835 1.146 0.820
## Phi for ui 0.821 0.093 0.601 0.837 0.955 0.876
##
## Deviance Information Criterion (DIC) ...............: 1686.20
## Deviance Information Criterion (DIC, saturated) ....: 801.88
## Effective number of parameters .....................: 225.70
##
## Watanabe-Akaike information criterion (WAIC) ...: 1680.27
## Effective number of parameters .................: 167.09
##
## Marginal log-Likelihood: -703.74
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
victoria_models_3 <- cma_models(victoria_sp@data,"Victoria","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
victoria_pedestrian <- clean_fixed_effects(victoria_models_3$fixed_effects)
map(victoria_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.188, Running = 0.343, Post = 0.167, Total = 0.698
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.400 0.087 -0.576 -0.398 -0.235 -0.398 0
## vandix_z 0.476 0.083 0.314 0.476 0.641 0.476 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.778 0.095 0.608 0.772 0.981 0.761
##
## Deviance Information Criterion (DIC) ...............: 1562.25
## Deviance Information Criterion (DIC, saturated) ....: 852.75
## Effective number of parameters .....................: 289.25
##
## Watanabe-Akaike information criterion (WAIC) ...: 1578.17
## Effective number of parameters .................: 217.49
##
## Marginal log-Likelihood: -869.32
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.3, Running = 0.822, Post = 0.18, Total = 16.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.428 0.074 -0.578 -0.427 -0.284 -0.427 0
## vandix_z 0.343 0.085 0.177 0.343 0.509 0.343 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.609 0.098 0.437 0.603 0.821 0.591
## Phi for ui 0.794 0.096 0.571 0.808 0.939 0.842
##
## Deviance Information Criterion (DIC) ...............: 1480.46
## Deviance Information Criterion (DIC, saturated) ....: 770.97
## Effective number of parameters .....................: 228.15
##
## Watanabe-Akaike information criterion (WAIC) ...: 1477.13
## Effective number of parameters .................: 167.72
##
## Marginal log-Likelihood: -578.10
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.5, Running = 0.866, Post = 0.189, Total = 16.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.417 0.071 -0.560 -0.417 -0.279 -0.417 0
## vandix_z 0.442 0.081 0.282 0.442 0.602 0.442 0
## ln_roads_km_c 0.847 0.118 0.617 0.847 1.080 0.847 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.587 0.087 0.433 0.582 0.775 0.571
## Phi for ui 0.951 0.045 0.828 0.965 0.996 0.988
##
## Deviance Information Criterion (DIC) ...............: 1439.74
## Deviance Information Criterion (DIC, saturated) ....: 730.24
## Effective number of parameters .....................: 198.88
##
## Watanabe-Akaike information criterion (WAIC) ...: 1430.00
## Effective number of parameters .................: 144.74
##
## Marginal log-Likelihood: -559.20
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15.6, Running = 0.938, Post = 0.207, Total = 16.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.297 0.090 -0.477 -0.296 -0.125
## vandix_z 0.311 0.082 0.150 0.311 0.471
## ln_roads_km_c 0.571 0.135 0.306 0.571 0.837
## roads_prop_highway_arterial_z 0.386 0.079 0.232 0.386 0.542
## ale_index_z 0.543 0.236 0.083 0.542 1.011
## canbics_index_z 0.343 0.235 -0.120 0.343 0.802
## population_100_c 0.036 0.014 0.009 0.036 0.064
## mode kld
## (Intercept) -0.296 0
## vandix_z 0.311 0
## ln_roads_km_c 0.571 0
## roads_prop_highway_arterial_z 0.386 0
## ale_index_z 0.542 0
## canbics_index_z 0.343 0
## population_100_c 0.036 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.724 0.119 0.515 0.716 0.981 0.702
## Phi for ui 0.924 0.066 0.745 0.944 0.993 0.980
##
## Deviance Information Criterion (DIC) ...............: 1426.57
## Deviance Information Criterion (DIC, saturated) ....: 717.08
## Effective number of parameters .....................: 184.56
##
## Watanabe-Akaike information criterion (WAIC) ...: 1418.88
## Effective number of parameters .................: 136.76
##
## Marginal log-Likelihood: -560.52
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
victoria_results <- bind_rows(victoria_all %>% mutate(Region = "Victoria",Outcome = "All Injury Claims"),
victoria_cyclist %>% mutate(Region = "Victoria",Outcome = "Cyclist Injury Claims"),
victoria_pedestrian %>% mutate(Region = "Victoria",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Central Island-Powell River | n_claims | 601 | 62,992.0 | 104.8 | 165.5 | 0.0 | 1,934.0 | 0 | 7 | 1.2 |
n_casualty_claims | 10,762.0 | 17.9 | 28.4 | 0.0 | 203.0 | 0 | 37 | 6.2 | ||
n_cyclist_claims | 475.0 | 0.8 | 1.5 | 0.0 | 14.0 | 0 | 355 | 59.1 | ||
n_cyclist_casualty_claims | 271.0 | 0.5 | 0.9 | 0.0 | 10.0 | 0 | 425 | 70.7 | ||
n_pedestrian_claims | 673.0 | 1.1 | 2.4 | 0.0 | 23.0 | 0 | 351 | 58.4 | ||
n_pedestrian_casualty_claims | 547.0 | 0.9 | 2.0 | 0.0 | 18.0 | 0 | 377 | 62.7 | ||
population | 357,163.0 | 594.3 | 301.0 | 0.0 | 2,466.0 | 0 | 5 | 0.8 | ||
total_roads_km | 5,652.1 | 9.4 | 9.9 | 0.1 | 86.5 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 78.2 | 0.1 | 0.2 | 0.0 | 0.8 | 0 | 262 | 43.6 | ||
no_highschool_prevalance | 101.2 | 0.2 | 0.1 | 0.0 | 0.6 | 28 | 1 | 0.2 | ||
unemployment_rate | 4,784.2 | 8.3 | 5.2 | 0.0 | 40.0 | 28 | 43 | 7.2 | ||
hh_avg_income | 36,682,051.0 | 65,738.4 | 17,197.1 | 29,925.0 | 211,531.0 | 43 | 0 | 0.0 | ||
participation_rate | 32,393.0 | 56.5 | 11.0 | 12.0 | 86.4 | 28 | 0 | 0.0 | ||
university_degree_prevalance | 300.2 | 0.5 | 0.1 | 0.2 | 0.8 | 28 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 95.7 | 0.2 | 0.1 | 0.0 | 0.6 | 28 | 3 | 0.5 | ||
home_owner_prevalence | 426.2 | 0.7 | 0.2 | 0.0 | 1.0 | 28 | 1 | 0.2 | ||
vandix | 111.8 | 0.2 | 0.7 | -1.1 | 4.0 | 43 | 0 | 0.0 | ||
ale_index | -590.4 | -1.1 | 0.7 | -2.1 | 1.5 | 47 | 0 | 0.0 | ||
canbics_index | 326.8 | 0.6 | 0.9 | 0.0 | 4.2 | 45 | 241 | 40.1 |
claims <- ggplot() +
geom_sf(data = nanaimo_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = nanaimo_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = nanaimo_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
nanaimo_sp <- as(nanaimo_sf, "Spatial")
nanaimo_sp$ui <- 1:nrow(nanaimo_sp@data)
coords <- coordinates(nanaimo_sp)
nanaimo_nb <- poly2nb(nanaimo_sp, queen = TRUE)
## Warning in poly2nb(nanaimo_sp, queen = TRUE): neighbour object has 5 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
nanaimo_nb
## Neighbour list object:
## Number of regions: 601
## Number of nonzero links: 3312
## Percentage nonzero weights: 0.916941
## Average number of links: 5.510815
## 5 disjoint connected subgraphs
#assign nearest neighbour for no links
nanaimo_nb <- assign_nearest_neighbors(nanaimo_nb,nanaimo_sp)
plot(nanaimo_sp, border = grey(0.5))
plot(nanaimo_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(nanaimo_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(nanaimo_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: nanaimo_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 12.045, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.3052806361 -0.0016666667 0.0006494328
cyc_cc_mi <- moran.test(nanaimo_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: nanaimo_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 6.6644, p-value = 1.328e-11
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.1663894111 -0.0016666667 0.0006358885
pd_cc_mi <- moran.test(nanaimo_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: nanaimo_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 8.5689, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2149591347 -0.0016666667 0.0006391025
nb2INLA("nanaimo.adj", nanaimo_nb)
g <- inla.read.graph(filename = "nanaimo.adj")
# Model Set 1: Total Casualty Claim Crashes
nanaimo_models_1 <- cma_models(nanaimo_sp@data, "Central Island-Powell River", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
nanaimo_all <- clean_fixed_effects(nanaimo_models_1$fixed_effects)
map(nanaimo_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.23, Running = 0.35, Post = 0.0738, Total = 0.654
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.969 0.058 1.854 1.969 2.083 1.969 0
## vandix_z 0.326 0.055 0.218 0.326 0.434 0.326 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.633 0.044 0.55 0.632 0.723 0.63
##
## Deviance Information Criterion (DIC) ...............: 3525.72
## Deviance Information Criterion (DIC, saturated) ....: 1233.27
## Effective number of parameters .....................: 553.20
##
## Watanabe-Akaike information criterion (WAIC) ...: 3560.31
## Effective number of parameters .................: 402.22
##
## Marginal log-Likelihood: -2298.87
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 16.2, Running = 0.883, Post = 0.202, Total = 17.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.98 0.051 1.878 1.98 2.079 1.98 0
## vandix_z 0.29 0.059 0.173 0.29 0.407 0.29 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.474 0.067 0.357 0.469 0.622 0.457
## Phi for ui 0.478 0.106 0.271 0.478 0.684 0.482
##
## Deviance Information Criterion (DIC) ...............: 3515.76
## Deviance Information Criterion (DIC, saturated) ....: 1223.31
## Effective number of parameters .....................: 547.76
##
## Watanabe-Akaike information criterion (WAIC) ...: 3543.60
## Effective number of parameters .................: 394.79
##
## Marginal log-Likelihood: -2179.69
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 16.5, Running = 0.995, Post = 0.167, Total = 17.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.437 0.061 1.317 1.438 1.556 1.438 0
## vandix_z 0.418 0.053 0.315 0.417 0.521 0.417 0
## ln_roads_km_c 0.971 0.070 0.835 0.971 1.109 0.971 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.484 0.060 0.377 0.480 0.615 0.472
## Phi for ui 0.684 0.066 0.544 0.688 0.801 0.698
##
## Deviance Information Criterion (DIC) ...............: 3456.63
## Deviance Information Criterion (DIC, saturated) ....: 1164.18
## Effective number of parameters .....................: 520.34
##
## Watanabe-Akaike information criterion (WAIC) ...: 3444.08
## Effective number of parameters .................: 353.05
##
## Marginal log-Likelihood: -2095.62
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 16.5, Running = 0.999, Post = 0.196, Total = 17.7
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) 2.114 0.118 1.881 2.114 2.345
## vandix_z 0.313 0.045 0.225 0.313 0.402
## ln_roads_km_c 0.619 0.073 0.476 0.619 0.763
## roads_prop_highway_arterial_z 0.662 0.047 0.569 0.661 0.755
## ale_index_z 1.434 0.244 0.957 1.434 1.913
## canbics_index_z -0.657 0.228 -1.106 -0.657 -0.211
## population_100_c 0.063 0.013 0.037 0.063 0.089
## mode kld
## (Intercept) 2.114 0
## vandix_z 0.313 0
## ln_roads_km_c 0.619 0
## roads_prop_highway_arterial_z 0.661 0
## ale_index_z 1.434 0
## canbics_index_z -0.657 0
## population_100_c 0.063 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.768 0.096 0.596 0.762 0.973 0.751
## Phi for ui 0.648 0.070 0.503 0.651 0.775 0.658
##
## Deviance Information Criterion (DIC) ...............: 3426.18
## Deviance Information Criterion (DIC, saturated) ....: 1133.72
## Effective number of parameters .....................: 490.47
##
## Watanabe-Akaike information criterion (WAIC) ...: 3391.55
## Effective number of parameters .................: 322.45
##
## Marginal log-Likelihood: -2020.82
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
nanaimo_models_2 <- cma_models(nanaimo_sp@data,"Central Island-Powell River","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
nanaimo_cyclist <- clean_fixed_effects(nanaimo_models_2$fixed_effects)
map(nanaimo_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.19, Running = 0.344, Post = 0.11, Total = 0.643
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.395 0.115 -1.630 -1.392 -1.177 -1.392 0
## vandix_z 0.280 0.072 0.139 0.280 0.421 0.280 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.19 0.238 0.806 1.16 1.73 1.11
##
## Deviance Information Criterion (DIC) ...............: 1019.00
## Deviance Information Criterion (DIC, saturated) ....: 621.37
## Effective number of parameters .....................: 146.46
##
## Watanabe-Akaike information criterion (WAIC) ...: 1013.31
## Effective number of parameters .................: 110.95
##
## Marginal log-Likelihood: -548.78
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 16.4, Running = 0.894, Post = 0.245, Total = 17.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.399 0.109 -1.622 -1.396 -1.190 -1.396 0
## vandix_z 0.314 0.074 0.169 0.314 0.459 0.314 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.077 0.242 0.689 1.047 1.638 0.985
## Phi for ui 0.311 0.144 0.080 0.295 0.624 0.249
##
## Deviance Information Criterion (DIC) ...............: 1008.22
## Deviance Information Criterion (DIC, saturated) ....: 610.59
## Effective number of parameters .....................: 136.69
##
## Watanabe-Akaike information criterion (WAIC) ...: 1004.54
## Effective number of parameters .................: 105.65
##
## Marginal log-Likelihood: -437.96
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 16.2, Running = 0.972, Post = 0.176, Total = 17.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.683 0.138 -1.961 -1.681 -1.419 -1.681 0
## vandix_z 0.374 0.075 0.227 0.374 0.521 0.374 0
## ln_roads_km_c 0.475 0.116 0.249 0.474 0.705 0.474 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.948 0.236 0.574 0.918 1.497 0.859
## Phi for ui 0.532 0.154 0.229 0.536 0.812 0.552
##
## Deviance Information Criterion (DIC) ...............: 991.67
## Deviance Information Criterion (DIC, saturated) ....: 594.04
## Effective number of parameters .....................: 126.50
##
## Watanabe-Akaike information criterion (WAIC) ...: 991.03
## Effective number of parameters .................: 100.43
##
## Marginal log-Likelihood: -435.16
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 16.6, Running = 1.02, Post = 0.222, Total = 17.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -1.050 0.207 -1.465 -1.047 -0.651
## vandix_z 0.334 0.076 0.186 0.334 0.482
## ln_roads_km_c 0.277 0.138 0.008 0.276 0.548
## roads_prop_highway_arterial_z 0.426 0.081 0.267 0.426 0.587
## ale_index_z 1.184 0.409 0.385 1.182 1.991
## canbics_index_z -0.239 0.365 -0.959 -0.237 0.475
## population_100_c 0.056 0.024 0.010 0.056 0.103
## mode kld
## (Intercept) -1.047 0
## vandix_z 0.334 0
## ln_roads_km_c 0.276 0
## roads_prop_highway_arterial_z 0.426 0
## ale_index_z 1.182 0
## canbics_index_z -0.237 0
## population_100_c 0.056 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.218 0.321 0.719 1.174 1.974 1.086
## Phi for ui 0.466 0.156 0.174 0.464 0.765 0.469
##
## Deviance Information Criterion (DIC) ...............: 968.35
## Deviance Information Criterion (DIC, saturated) ....: 570.71
## Effective number of parameters .....................: 113.36
##
## Watanabe-Akaike information criterion (WAIC) ...: 968.76
## Effective number of parameters .................: 91.87
##
## Marginal log-Likelihood: -436.30
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
nanaimo_models_3 <- cma_models(nanaimo_sp@data,"Central Island-Powell River","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
nanaimo_pedestrian <- clean_fixed_effects(nanaimo_models_3$fixed_effects)
map(nanaimo_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.199, Running = 0.346, Post = 0.0696, Total = 0.614
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.243 0.123 -1.497 -1.239 -1.013 -1.239 0
## vandix_z 0.517 0.075 0.372 0.517 0.665 0.517 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.631 0.084 0.483 0.626 0.81 0.615
##
## Deviance Information Criterion (DIC) ...............: 1367.05
## Deviance Information Criterion (DIC, saturated) ....: 801.25
## Effective number of parameters .....................: 285.30
##
## Watanabe-Akaike information criterion (WAIC) ...: 1400.20
## Effective number of parameters .................: 221.21
##
## Marginal log-Likelihood: -757.92
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 16.4, Running = 0.877, Post = 0.191, Total = 17.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.213 0.115 -1.453 -1.209 -0.999 -1.209 0
## vandix_z 0.524 0.077 0.375 0.524 0.676 0.524 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.607 0.099 0.441 0.597 0.831 0.574
## Phi for ui 0.206 0.125 0.032 0.181 0.502 0.107
##
## Deviance Information Criterion (DIC) ...............: 1351.33
## Deviance Information Criterion (DIC, saturated) ....: 785.53
## Effective number of parameters .....................: 272.72
##
## Watanabe-Akaike information criterion (WAIC) ...: 1371.85
## Effective number of parameters .................: 206.15
##
## Marginal log-Likelihood: -651.06
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 16.7, Running = 0.926, Post = 0.184, Total = 17.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.540 0.139 -1.821 -1.538 -1.275 -1.538 0
## vandix_z 0.578 0.078 0.425 0.578 0.733 0.578 0
## ln_roads_km_c 0.614 0.130 0.361 0.613 0.870 0.613 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.470 0.104 0.302 0.458 0.709 0.434
## Phi for ui 0.578 0.143 0.281 0.587 0.827 0.620
##
## Deviance Information Criterion (DIC) ...............: 1312.28
## Deviance Information Criterion (DIC, saturated) ....: 746.48
## Effective number of parameters .....................: 240.68
##
## Watanabe-Akaike information criterion (WAIC) ...: 1324.29
## Effective number of parameters .................: 181.98
##
## Marginal log-Likelihood: -645.55
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 16.5, Running = 1.02, Post = 0.236, Total = 17.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.644 0.206 -1.056 -0.641 -0.249
## vandix_z 0.494 0.074 0.349 0.494 0.639
## ln_roads_km_c 0.308 0.139 0.037 0.308 0.581
## roads_prop_highway_arterial_z 0.549 0.081 0.391 0.549 0.710
## ale_index_z 2.409 0.391 1.647 2.407 3.181
## canbics_index_z -1.066 0.349 -1.757 -1.064 -0.387
## population_100_c 0.112 0.023 0.068 0.112 0.157
## mode kld
## (Intercept) -0.641 0
## vandix_z 0.494 0
## ln_roads_km_c 0.308 0
## roads_prop_highway_arterial_z 0.549 0
## ale_index_z 2.407 0
## canbics_index_z -1.064 0
## population_100_c 0.112 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.765 0.161 0.504 0.746 1.136 0.707
## Phi for ui 0.423 0.150 0.150 0.419 0.718 0.420
##
## Deviance Information Criterion (DIC) ...............: 1262.65
## Deviance Information Criterion (DIC, saturated) ....: 696.85
## Effective number of parameters .....................: 201.64
##
## Watanabe-Akaike information criterion (WAIC) ...: 1262.54
## Effective number of parameters .................: 150.54
##
## Marginal log-Likelihood: -621.15
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
nanaimo_results <- bind_rows(nanaimo_all %>% mutate(Region = "Central Island-Powell River",Outcome = "All Injury Claims"),
nanaimo_cyclist %>% mutate(Region = "Central Island-Powell River",Outcome = "Cyclist Injury Claims"),
nanaimo_pedestrian %>% mutate(Region = "Central Island-Powell River",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Okanagan | n_claims | 464 | 70,024.0 | 150.9 | 326.1 | 0.0 | 4,324.0 | 0 | 8 | 1.7 |
n_casualty_claims | 13,236.0 | 28.5 | 66.7 | 0.0 | 938.0 | 0 | 36 | 7.8 | ||
n_cyclist_claims | 761.0 | 1.6 | 3.8 | 0.0 | 38.0 | 0 | 250 | 53.9 | ||
n_cyclist_casualty_claims | 485.0 | 1.0 | 2.3 | 0.0 | 23.0 | 0 | 284 | 61.2 | ||
n_pedestrian_claims | 696.0 | 1.5 | 3.9 | 0.0 | 41.0 | 0 | 257 | 55.4 | ||
n_pedestrian_casualty_claims | 564.0 | 1.2 | 3.2 | 0.0 | 35.0 | 0 | 272 | 58.6 | ||
population | 336,628.0 | 725.5 | 488.3 | 0.0 | 4,622.0 | 0 | 8 | 1.7 | ||
total_roads_km | 4,759.1 | 10.3 | 13.6 | 0.0 | 139.3 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 60.1 | 0.1 | 0.2 | 0.0 | 1.0 | 0 | 199 | 42.9 | ||
no_highschool_prevalance | 62.0 | 0.2 | 0.1 | 0.0 | 0.4 | 86 | 4 | 0.9 | ||
unemployment_rate | 2,933.5 | 7.8 | 4.7 | 0.0 | 33.3 | 86 | 28 | 6.0 | ||
hh_avg_income | 26,784,003.0 | 72,980.9 | 26,808.0 | 26,241.0 | 247,493.0 | 97 | 0 | 0.0 | ||
participation_rate | 23,166.9 | 61.3 | 12.9 | 9.2 | 91.5 | 86 | 0 | 0.0 | ||
university_degree_prevalance | 199.0 | 0.5 | 0.1 | 0.3 | 0.8 | 86 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 59.9 | 0.2 | 0.1 | 0.0 | 0.5 | 86 | 4 | 0.9 | ||
home_owner_prevalence | 275.1 | 0.7 | 0.2 | 0.0 | 1.3 | 86 | 0 | 0.0 | ||
vandix | 42.6 | 0.1 | 0.6 | -1.2 | 2.2 | 97 | 0 | 0.0 | ||
ale_index | -314.5 | -0.8 | 1.0 | -2.1 | 2.3 | 91 | 1 | 0.2 | ||
canbics_index | 709.8 | 1.9 | 1.8 | 0.0 | 7.2 | 91 | 82 | 17.7 |
claims <- ggplot() +
geom_sf(data = okanagan_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = okanagan_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = okanagan_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
okanagan_sp <- as(okanagan_sf, "Spatial")
okanagan_sp$ui <- 1:nrow(okanagan_sp@data)
coords <- coordinates(okanagan_sp)
okanagan_nb <- poly2nb(okanagan_sp, queen = TRUE,snap = 1)
okanagan_nb
## Neighbour list object:
## Number of regions: 464
## Number of nonzero links: 2720
## Percentage nonzero weights: 1.263377
## Average number of links: 5.862069
#assign nearest neighbour for no links
# okanagan_nb <- assign_nearest_neighbors(okanagan_nb,okanagan_sp)
plot(okanagan_sp, border = grey(0.5))
plot(okanagan_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(okanagan_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(okanagan_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: okanagan_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 14.418, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.3622147009 -0.0021598272 0.0006386753
cyc_cc_mi <- moran.test(okanagan_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: okanagan_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 14.971, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.3999237322 -0.0021598272 0.0007213349
pd_cc_mi <- moran.test(okanagan_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: okanagan_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 8.8393, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2314383441 -0.0021598272 0.0006983917
nb2INLA("okanagan.adj", okanagan_nb)
g <- inla.read.graph(filename = "okanagan.adj")
# Model Set 1: Total Casualty Claim Crashes
okanagan_models_1 <- cma_models(okanagan_sp@data, "Okanagan", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
okanagan_all <- clean_fixed_effects(okanagan_models_1$fixed_effects)
map(okanagan_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.203, Running = 0.339, Post = 0.0737, Total = 0.616
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.176 0.073 2.031 2.177 2.319 2.177 0
## vandix_z 0.442 0.084 0.279 0.442 0.607 0.442 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.471 0.037 0.402 0.47 0.546 0.467
##
## Deviance Information Criterion (DIC) ...............: 2820.09
## Deviance Information Criterion (DIC, saturated) ....: 969.14
## Effective number of parameters .....................: 439.12
##
## Watanabe-Akaike information criterion (WAIC) ...: 2859.13
## Effective number of parameters .................: 324.59
##
## Marginal log-Likelihood: -1924.88
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.2, Running = 0.891, Post = 0.145, Total = 16.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.179 0.047 2.087 2.179 2.270 2.179 0
## vandix_z 0.329 0.091 0.151 0.329 0.507 0.329 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.240 0.037 0.175 0.238 0.320 0.233
## Phi for ui 0.842 0.059 0.705 0.850 0.932 0.866
##
## Deviance Information Criterion (DIC) ...............: 2777.98
## Deviance Information Criterion (DIC, saturated) ....: 927.03
## Effective number of parameters .....................: 421.57
##
## Watanabe-Akaike information criterion (WAIC) ...: 2779.92
## Effective number of parameters .................: 290.97
##
## Marginal log-Likelihood: -1781.47
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.2, Running = 0.857, Post = 0.164, Total = 16.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.597 0.052 1.493 1.597 1.699 1.597 0
## vandix_z 0.438 0.073 0.294 0.438 0.582 0.438 0
## ln_roads_km_c 1.136 0.073 0.993 1.136 1.280 1.136 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.243 0.022 0.200 0.242 0.287 0.242
## Phi for ui 0.985 0.013 0.949 0.989 0.999 0.996
##
## Deviance Information Criterion (DIC) ...............: 2701.46
## Deviance Information Criterion (DIC, saturated) ....: 850.50
## Effective number of parameters .....................: 385.80
##
## Watanabe-Akaike information criterion (WAIC) ...: 2649.57
## Effective number of parameters .................: 235.72
##
## Marginal log-Likelihood: -1686.96
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15.2, Running = 0.859, Post = 0.315, Total = 16.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode
## (Intercept) 1.990 0.084 1.823 1.990 2.154 1.990
## vandix_z 0.336 0.064 0.210 0.336 0.462 0.336
## ln_roads_km_c 0.949 0.076 0.800 0.949 1.098 0.949
## roads_prop_highway_arterial_z 0.599 0.054 0.492 0.599 0.706 0.599
## ale_index_z 0.536 0.263 0.020 0.536 1.052 0.536
## canbics_index_z 0.032 0.215 -0.390 0.031 0.454 0.031
## population_100_c 0.030 0.009 0.014 0.030 0.047 0.030
## kld
## (Intercept) 0
## vandix_z 0
## ln_roads_km_c 0
## roads_prop_highway_arterial_z 0
## ale_index_z 0
## canbics_index_z 0
## population_100_c 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.341 0.037 0.271 0.340 0.415 0.342
## Phi for ui 0.979 0.020 0.927 0.985 0.998 0.995
##
## Deviance Information Criterion (DIC) ...............: 2692.22
## Deviance Information Criterion (DIC, saturated) ....: 841.26
## Effective number of parameters .....................: 370.67
##
## Watanabe-Akaike information criterion (WAIC) ...: 2639.76
## Effective number of parameters .................: 226.92
##
## Marginal log-Likelihood: -1648.95
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
okanagan_models_2 <- cma_models(okanagan_sp@data,"Okanagan","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
okanagan_cyclist <- clean_fixed_effects(okanagan_models_2$fixed_effects)
map(okanagan_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.174, Running = 0.309, Post = 0.0941, Total = 0.577
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.110 0.136 -1.392 -1.104 -0.857 -1.083 0
## vandix_z 0.665 0.103 0.467 0.664 0.870 0.664 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.591 0.086 0.44 0.585 0.776 0.574
##
## Deviance Information Criterion (DIC) ...............: 1108.00
## Deviance Information Criterion (DIC, saturated) ....: 639.28
## Effective number of parameters .....................: 233.10
##
## Watanabe-Akaike information criterion (WAIC) ...: 1142.81
## Effective number of parameters .................: 184.75
##
## Marginal log-Likelihood: -625.00
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.3, Running = 0.691, Post = 0.152, Total = 16.1
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.104 0.110 -1.327 -1.102 -0.893 -1.102 0
## vandix_z 0.618 0.108 0.408 0.618 0.832 0.618 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.416 0.090 0.263 0.407 0.617 0.392
## Phi for ui 0.799 0.092 0.582 0.813 0.937 0.845
##
## Deviance Information Criterion (DIC) ...............: 994.90
## Deviance Information Criterion (DIC, saturated) ....: 526.17
## Effective number of parameters .....................: 160.48
##
## Watanabe-Akaike information criterion (WAIC) ...: 993.45
## Effective number of parameters .................: 117.58
##
## Marginal log-Likelihood: -488.84
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.1, Running = 0.727, Post = 0.194, Total = 16.1
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.493 0.139 -1.773 -1.490 -1.225 -1.491 0
## vandix_z 0.676 0.104 0.474 0.676 0.882 0.676 0
## ln_roads_km_c 0.711 0.121 0.474 0.711 0.951 0.711 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.333 0.06 0.228 0.329 0.465 0.321
## Phi for ui 0.954 0.04 0.847 0.965 0.995 0.985
##
## Deviance Information Criterion (DIC) ...............: 964.39
## Deviance Information Criterion (DIC, saturated) ....: 495.66
## Effective number of parameters .....................: 141.22
##
## Watanabe-Akaike information criterion (WAIC) ...: 957.61
## Effective number of parameters .................: 101.59
##
## Marginal log-Likelihood: -478.14
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15, Running = 0.756, Post = 0.189, Total = 16
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.989 0.165 -1.320 -0.987 -0.673
## vandix_z 0.545 0.099 0.351 0.544 0.741
## ln_roads_km_c 0.612 0.137 0.344 0.612 0.882
## roads_prop_highway_arterial_z 0.396 0.089 0.222 0.396 0.570
## ale_index_z 0.730 0.380 -0.014 0.730 1.476
## canbics_index_z 0.361 0.292 -0.214 0.362 0.934
## population_100_c 0.036 0.015 0.008 0.036 0.065
## mode kld
## (Intercept) -0.987 0
## vandix_z 0.544 0
## ln_roads_km_c 0.612 0
## roads_prop_highway_arterial_z 0.396 0
## ale_index_z 0.730 0
## canbics_index_z 0.362 0
## population_100_c 0.036 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.424 0.080 0.286 0.417 0.601 0.405
## Phi for ui 0.962 0.037 0.862 0.974 0.997 0.992
##
## Deviance Information Criterion (DIC) ...............: 951.85
## Deviance Information Criterion (DIC, saturated) ....: 483.12
## Effective number of parameters .....................: 124.57
##
## Watanabe-Akaike information criterion (WAIC) ...: 945.73
## Effective number of parameters .................: 91.64
##
## Marginal log-Likelihood: -480.85
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
okanagan_models_3 <- cma_models(okanagan_sp@data,"Okanagan","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
okanagan_pedestrian <- clean_fixed_effects(okanagan_models_3$fixed_effects)
map(okanagan_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.214, Running = 0.312, Post = 0.086, Total = 0.612
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.064 0.131 -1.335 -1.059 -0.819 -1.059 0
## vandix_z 0.623 0.103 0.423 0.622 0.827 0.622 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.554 0.074 0.421 0.549 0.712 0.54
##
## Deviance Information Criterion (DIC) ...............: 1152.02
## Deviance Information Criterion (DIC, saturated) ....: 657.89
## Effective number of parameters .....................: 246.82
##
## Watanabe-Akaike information criterion (WAIC) ...: 1197.10
## Effective number of parameters .................: 198.98
##
## Marginal log-Likelihood: -650.99
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15, Running = 0.71, Post = 0.139, Total = 15.9
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.032 0.117 -1.274 -1.029 -0.813 -1.029 0
## vandix_z 0.645 0.110 0.428 0.645 0.861 0.645 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.515 0.088 0.365 0.507 0.71 0.492
## Phi for ui 0.346 0.124 0.133 0.336 0.61 0.314
##
## Deviance Information Criterion (DIC) ...............: 1113.50
## Deviance Information Criterion (DIC, saturated) ....: 619.37
## Effective number of parameters .....................: 219.98
##
## Watanabe-Akaike information criterion (WAIC) ...: 1131.58
## Effective number of parameters .................: 166.72
##
## Marginal log-Likelihood: -555.26
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.2, Running = 0.723, Post = 0.164, Total = 16.1
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.428 0.138 -1.706 -1.426 -1.163 -1.426 0
## vandix_z 0.693 0.118 0.462 0.692 0.925 0.692 0
## ln_roads_km_c 0.803 0.136 0.537 0.802 1.071 0.802 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.357 0.079 0.224 0.350 0.536 0.335
## Phi for ui 0.770 0.108 0.518 0.787 0.932 0.827
##
## Deviance Information Criterion (DIC) ...............: 1069.25
## Deviance Information Criterion (DIC, saturated) ....: 575.11
## Effective number of parameters .....................: 184.54
##
## Watanabe-Akaike information criterion (WAIC) ...: 1069.33
## Effective number of parameters .................: 134.51
##
## Marginal log-Likelihood: -543.63
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15, Running = 0.793, Post = 0.181, Total = 16
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.836 0.160 -1.157 -0.834 -0.530
## vandix_z 0.532 0.111 0.314 0.532 0.750
## ln_roads_km_c 0.634 0.150 0.339 0.634 0.930
## roads_prop_highway_arterial_z 0.574 0.088 0.403 0.574 0.748
## ale_index_z 1.330 0.392 0.565 1.329 2.103
## canbics_index_z -0.240 0.322 -0.875 -0.240 0.390
## population_100_c 0.049 0.016 0.018 0.049 0.080
## mode kld
## (Intercept) -0.834 0
## vandix_z 0.532 0
## ln_roads_km_c 0.634 0
## roads_prop_highway_arterial_z 0.574 0
## ale_index_z 1.329 0
## canbics_index_z -0.240 0
## population_100_c 0.049 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.494 0.120 0.299 0.481 0.767 0.456
## Phi for ui 0.722 0.131 0.422 0.740 0.920 0.790
##
## Deviance Information Criterion (DIC) ...............: 1039.35
## Deviance Information Criterion (DIC, saturated) ....: 545.21
## Effective number of parameters .....................: 163.80
##
## Watanabe-Akaike information criterion (WAIC) ...: 1034.42
## Effective number of parameters .................: 118.27
##
## Marginal log-Likelihood: -535.00
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
okanagan_results <- bind_rows(okanagan_all %>% mutate(Region = "Okanagan",Outcome = "All Injury Claims"),
okanagan_cyclist %>% mutate(Region = "Okanagan",Outcome = "Cyclist Injury Claims"),
okanagan_pedestrian %>% mutate(Region = "Okanagan",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Fraser Valley | n_claims | 472 | 68,269.0 | 144.6 | 279.9 | 0.0 | 2,538.0 | 0 | 4 | 0.8 |
n_casualty_claims | 15,730.0 | 33.3 | 65.2 | 0.0 | 556.0 | 0 | 17 | 3.6 | ||
n_cyclist_claims | 581.0 | 1.2 | 2.4 | 0.0 | 21.0 | 0 | 248 | 52.5 | ||
n_cyclist_casualty_claims | 360.0 | 0.8 | 1.6 | 0.0 | 12.0 | 0 | 302 | 64.0 | ||
n_pedestrian_claims | 894.0 | 1.9 | 3.7 | 0.0 | 32.0 | 0 | 205 | 43.4 | ||
n_pedestrian_casualty_claims | 725.0 | 1.5 | 3.0 | 0.0 | 25.0 | 0 | 225 | 47.7 | ||
population | 309,493.0 | 655.7 | 341.8 | 0.0 | 2,550.0 | 0 | 4 | 0.8 | ||
total_roads_km | 3,678.9 | 7.8 | 9.6 | 0.1 | 81.8 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 40.5 | 0.1 | 0.1 | 0.0 | 0.7 | 0 | 281 | 59.5 | ||
no_highschool_prevalance | 82.9 | 0.2 | 0.1 | 0.1 | 0.5 | 88 | 0 | 0.0 | ||
unemployment_rate | 2,706.8 | 7.0 | 5.1 | 0.0 | 30.0 | 88 | 45 | 9.5 | ||
hh_avg_income | 27,748,698.0 | 75,404.1 | 21,091.5 | 24,502.0 | 161,236.0 | 104 | 0 | 0.0 | ||
participation_rate | 24,427.3 | 63.6 | 11.6 | 12.7 | 82.2 | 88 | 0 | 0.0 | ||
university_degree_prevalance | 170.5 | 0.4 | 0.1 | 0.1 | 0.7 | 88 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 63.8 | 0.2 | 0.1 | 0.0 | 1.0 | 87 | 3 | 0.6 | ||
home_owner_prevalence | 284.5 | 0.7 | 0.2 | 0.0 | 1.0 | 88 | 1 | 0.2 | ||
vandix | 112.4 | 0.3 | 0.6 | -0.9 | 2.0 | 104 | 0 | 0.0 | ||
ale_index | -89.0 | -0.2 | 1.7 | -2.1 | 6.7 | 101 | 1 | 0.2 | ||
canbics_index | 514.5 | 1.4 | 1.3 | 0.0 | 4.9 | 101 | 81 | 17.2 |
claims <- ggplot() +
geom_sf(data = fraser_valley_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = fraser_valley_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = fraser_valley_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
fraser_valley_sp <- as(fraser_valley_sf, "Spatial")
fraser_valley_sp$ui <- 1:nrow(fraser_valley_sp@data)
coords <- coordinates(fraser_valley_sp)
fraser_valley_nb <- poly2nb(fraser_valley_sp, queen = TRUE)
## Warning in poly2nb(fraser_valley_sp, queen = TRUE): neighbour object has 2 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
fraser_valley_nb
## Neighbour list object:
## Number of regions: 472
## Number of nonzero links: 2822
## Percentage nonzero weights: 1.266698
## Average number of links: 5.978814
## 2 disjoint connected subgraphs
#assign nearest neighbour for no links
fraser_valley_nb <- assign_nearest_neighbors(fraser_valley_nb,fraser_valley_sp)
plot(fraser_valley_sp, border = grey(0.5))
plot(fraser_valley_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(fraser_valley_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(fraser_valley_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: fraser_valley_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 8.2045, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2194714130 -0.0021231423 0.0007294782
cyc_cc_mi <- moran.test(fraser_valley_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: fraser_valley_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 8.2775, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2236414065 -0.0021231423 0.0007438924
pd_cc_mi <- moran.test(fraser_valley_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: fraser_valley_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 9.3134, p-value < 2.2e-16
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.2508545992 -0.0021231423 0.0007378148
nb2INLA("fraser_valley.adj", fraser_valley_nb)
g <- inla.read.graph(filename = "fraser_valley.adj")
# Model Set 1: Total Casualty Claim Crashes
fraser_valley_models_1 <- cma_models(fraser_valley_sp@data, "Fraser Valley", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
fraser_valley_all <- clean_fixed_effects(fraser_valley_models_1$fixed_effects)
map(fraser_valley_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.218, Running = 0.32, Post = 0.0963, Total = 0.634
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.470 0.068 2.335 2.470 2.603 2.470 0
## vandix_z 0.335 0.071 0.195 0.335 0.476 0.335 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.604 0.045 0.52 0.603 0.696 0.601
##
## Deviance Information Criterion (DIC) ...............: 3035.43
## Deviance Information Criterion (DIC, saturated) ....: 972.17
## Effective number of parameters .....................: 448.98
##
## Watanabe-Akaike information criterion (WAIC) ...: 3030.94
## Effective number of parameters .................: 306.12
##
## Marginal log-Likelihood: -2059.30
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.5, Running = 0.677, Post = 0.143, Total = 16.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.482 0.038 2.407 2.482 2.557 2.482 0
## vandix_z 0.210 0.083 0.047 0.210 0.373 0.210 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.282 0.021 0.243 0.281 0.325 0.28
## Phi for ui 1.000 0.000 1.000 1.000 1.000 1.00
##
## Deviance Information Criterion (DIC) ...............: 2989.21
## Deviance Information Criterion (DIC, saturated) ....: 925.94
## Effective number of parameters .....................: 424.39
##
## Watanabe-Akaike information criterion (WAIC) ...: 2957.13
## Effective number of parameters .................: 274.73
##
## Marginal log-Likelihood: -1823.41
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.6, Running = 0.765, Post = 0.158, Total = 16.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 2.271 0.043 2.186 2.271 2.354 2.271 0
## vandix_z 0.273 0.065 0.145 0.273 0.400 0.273 0
## ln_roads_km_c 1.105 0.067 0.973 1.105 1.237 1.105 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.708 0.068 0.583 0.705 0.852 0.70
## Phi for ui 0.804 0.054 0.683 0.809 0.894 0.82
##
## Deviance Information Criterion (DIC) ...............: 2985.13
## Deviance Information Criterion (DIC, saturated) ....: 921.86
## Effective number of parameters .....................: 417.89
##
## Watanabe-Akaike information criterion (WAIC) ...: 2950.41
## Effective number of parameters .................: 269.05
##
## Marginal log-Likelihood: -1675.37
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15.4, Running = 0.861, Post = 0.205, Total = 16.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode
## (Intercept) 2.723 0.060 2.605 2.723 2.840 2.723
## vandix_z 0.132 0.059 0.017 0.132 0.247 0.132
## ln_roads_km_c 0.863 0.072 0.722 0.863 1.005 0.863
## roads_prop_highway_arterial_z 0.581 0.059 0.466 0.581 0.697 0.581
## ale_index_z 0.249 0.127 0.001 0.249 0.498 0.249
## canbics_index_z 0.181 0.141 -0.099 0.181 0.456 0.181
## population_100_c 0.027 0.012 0.002 0.026 0.051 0.026
## kld
## (Intercept) 0
## vandix_z 0
## ln_roads_km_c 0
## roads_prop_highway_arterial_z 0
## ale_index_z 0
## canbics_index_z 0
## population_100_c 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.951 0.104 0.758 0.946 1.167 0.940
## Phi for ui 0.806 0.066 0.657 0.813 0.914 0.827
##
## Deviance Information Criterion (DIC) ...............: 2973.45
## Deviance Information Criterion (DIC, saturated) ....: 910.18
## Effective number of parameters .....................: 403.87
##
## Watanabe-Akaike information criterion (WAIC) ...: 2931.10
## Effective number of parameters .................: 256.43
##
## Marginal log-Likelihood: -1641.12
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
fraser_valley_models_2 <- cma_models(fraser_valley_sp@data,"Fraser Valley","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
fraser_valley_cyclist <- clean_fixed_effects(fraser_valley_models_2$fixed_effects)
map(fraser_valley_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.18, Running = 0.305, Post = 0.0721, Total = 0.557
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.268 0.136 -1.548 -1.263 -1.013 -1.263 0
## vandix_z 0.419 0.096 0.231 0.418 0.609 0.418 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.707 0.111 0.515 0.699 0.949 0.682
##
## Deviance Information Criterion (DIC) ...............: 1013.45
## Deviance Information Criterion (DIC, saturated) ....: 598.20
## Effective number of parameters .....................: 196.91
##
## Watanabe-Akaike information criterion (WAIC) ...: 1022.81
## Effective number of parameters .................: 147.69
##
## Marginal log-Likelihood: -564.34
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.4, Running = 0.725, Post = 0.153, Total = 16.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.211 0.125 -1.469 -1.207 -0.976 -1.208 0
## vandix_z 0.316 0.112 0.094 0.317 0.535 0.317 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.672 0.112 0.481 0.662 0.921 0.642
## Phi for ui 0.326 0.129 0.108 0.316 0.600 0.293
##
## Deviance Information Criterion (DIC) ...............: 998.05
## Deviance Information Criterion (DIC, saturated) ....: 582.80
## Effective number of parameters .....................: 186.00
##
## Watanabe-Akaike information criterion (WAIC) ...: 1004.13
## Effective number of parameters .................: 139.05
##
## Marginal log-Likelihood: -315.57
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.4, Running = 0.793, Post = 0.168, Total = 16.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.353 0.123 -1.602 -1.351 -1.118 -1.351 0
## vandix_z 0.267 0.112 0.047 0.267 0.487 0.267 0
## ln_roads_km_c 0.756 0.127 0.509 0.755 1.007 0.755 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.617 0.113 0.423 0.608 0.865 0.591
## Phi for ui 0.758 0.119 0.486 0.776 0.937 0.822
##
## Deviance Information Criterion (DIC) ...............: 960.73
## Deviance Information Criterion (DIC, saturated) ....: 545.48
## Effective number of parameters .....................: 153.40
##
## Watanabe-Akaike information criterion (WAIC) ...: 964.76
## Effective number of parameters .................: 117.75
##
## Marginal log-Likelihood: -303.63
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15.5, Running = 0.842, Post = 0.181, Total = 16.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.785 0.144 -1.075 -0.783 -0.508
## vandix_z 0.070 0.110 -0.147 0.070 0.284
## ln_roads_km_c 0.468 0.134 0.208 0.467 0.732
## roads_prop_highway_arterial_z 0.603 0.101 0.406 0.603 0.802
## ale_index_z 0.698 0.214 0.279 0.698 1.118
## canbics_index_z 0.092 0.299 -0.495 0.092 0.678
## population_100_c 0.046 0.023 0.001 0.046 0.091
## mode kld
## (Intercept) -0.783 0
## vandix_z 0.070 0
## ln_roads_km_c 0.467 0
## roads_prop_highway_arterial_z 0.603 0
## ale_index_z 0.698 0
## canbics_index_z 0.092 0
## population_100_c 0.046 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.893 0.185 0.585 0.874 1.310 0.837
## Phi for ui 0.615 0.159 0.283 0.628 0.883 0.666
##
## Deviance Information Criterion (DIC) ...............: 941.57
## Deviance Information Criterion (DIC, saturated) ....: 526.32
## Effective number of parameters .....................: 136.46
##
## Watanabe-Akaike information criterion (WAIC) ...: 942.32
## Effective number of parameters .................: 105.04
##
## Marginal log-Likelihood: -300.36
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
fraser_valley_models_3 <- cma_models(fraser_valley_sp@data,"Fraser Valley","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
fraser_valley_pedestrian <- clean_fixed_effects(fraser_valley_models_3$fixed_effects)
map(fraser_valley_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.213, Running = 0.331, Post = 0.0776, Total = 0.621
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.600 0.102 -0.807 -0.598 -0.406 -0.598 0
## vandix_z 0.566 0.081 0.408 0.565 0.727 0.565 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.781 0.099 0.605 0.776 0.992 0.764
##
## Deviance Information Criterion (DIC) ...............: 1374.29
## Deviance Information Criterion (DIC, saturated) ....: 722.68
## Effective number of parameters .....................: 252.29
##
## Watanabe-Akaike information criterion (WAIC) ...: 1389.45
## Effective number of parameters .................: 189.47
##
## Marginal log-Likelihood: -773.86
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.2, Running = 0.79, Post = 0.207, Total = 16.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.577 0.095 -0.770 -0.575 -0.395 -0.575 0
## vandix_z 0.485 0.094 0.302 0.485 0.669 0.485 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.733 0.103 0.552 0.726 0.956 0.711
## Phi for ui 0.381 0.115 0.174 0.375 0.617 0.366
##
## Deviance Information Criterion (DIC) ...............: 1347.47
## Deviance Information Criterion (DIC, saturated) ....: 695.86
## Effective number of parameters .....................: 236.95
##
## Watanabe-Akaike information criterion (WAIC) ...: 1354.34
## Effective number of parameters .................: 174.73
##
## Marginal log-Likelihood: -517.70
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.3, Running = 0.784, Post = 0.172, Total = 16.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -0.723 0.092 -0.906 -0.722 -0.545 -0.722 0
## vandix_z 0.431 0.090 0.255 0.431 0.608 0.431 0
## ln_roads_km_c 0.815 0.104 0.610 0.816 1.019 0.816 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.654 0.102 0.473 0.648 0.873 0.637
## Phi for ui 0.856 0.085 0.646 0.873 0.971 0.915
##
## Deviance Information Criterion (DIC) ...............: 1296.05
## Deviance Information Criterion (DIC, saturated) ....: 644.44
## Effective number of parameters .....................: 194.29
##
## Watanabe-Akaike information criterion (WAIC) ...: 1294.06
## Effective number of parameters .................: 143.15
##
## Marginal log-Likelihood: -495.51
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15.2, Running = 0.818, Post = 0.249, Total = 16.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.205 0.113 -0.431 -0.203 0.014
## vandix_z 0.270 0.086 0.102 0.270 0.438
## ln_roads_km_c 0.422 0.114 0.199 0.421 0.646
## roads_prop_highway_arterial_z 0.622 0.082 0.461 0.621 0.784
## ale_index_z 0.494 0.178 0.146 0.494 0.842
## canbics_index_z 0.021 0.239 -0.449 0.021 0.489
## population_100_c 0.059 0.019 0.023 0.059 0.097
## mode kld
## (Intercept) -0.203 0
## vandix_z 0.270 0
## ln_roads_km_c 0.421 0
## roads_prop_highway_arterial_z 0.621 0
## ale_index_z 0.494 0
## canbics_index_z 0.021 0
## population_100_c 0.059 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.041 0.18 0.730 1.026 1.435 0.999
## Phi for ui 0.678 0.13 0.395 0.691 0.893 0.723
##
## Deviance Information Criterion (DIC) ...............: 1271.84
## Deviance Information Criterion (DIC, saturated) ....: 620.23
## Effective number of parameters .....................: 174.02
##
## Watanabe-Akaike information criterion (WAIC) ...: 1264.96
## Effective number of parameters .................: 127.05
##
## Marginal log-Likelihood: -483.15
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
fraser_valley_results <- bind_rows(fraser_valley_all %>% mutate(Region = "Fraser Valley",Outcome = "All Injury Claims"),
fraser_valley_cyclist %>% mutate(Region = "Fraser Valley",Outcome = "Cyclist Injury Claims"),
fraser_valley_pedestrian %>% mutate(Region = "Fraser Valley",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
North Central | n_claims | 350 | 31,422.0 | 89.8 | 182.3 | 0.0 | 1,906.0 | 0 | 13 | 3.7 |
n_casualty_claims | 4,490.0 | 12.8 | 25.4 | 0.0 | 228.0 | 0 | 48 | 13.7 | ||
n_cyclist_claims | 107.0 | 0.3 | 1.0 | 0.0 | 11.0 | 0 | 287 | 82.0 | ||
n_cyclist_casualty_claims | 54.0 | 0.2 | 0.6 | 0.0 | 5.0 | 0 | 314 | 89.7 | ||
n_pedestrian_claims | 241.0 | 0.7 | 2.0 | 0.0 | 27.0 | 0 | 240 | 68.6 | ||
n_pedestrian_casualty_claims | 203.0 | 0.6 | 1.6 | 0.0 | 21.0 | 0 | 253 | 72.3 | ||
population | 182,780.0 | 525.2 | 277.1 | 0.0 | 2,479.0 | 2 | 4 | 1.1 | ||
total_roads_km | 9,989.6 | 28.5 | 54.4 | 0.9 | 398.4 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 45.4 | 0.1 | 0.1 | 0.0 | 0.7 | 0 | 132 | 37.7 | ||
no_highschool_prevalance | 74.8 | 0.2 | 0.1 | 0.1 | 0.8 | 21 | 0 | 0.0 | ||
unemployment_rate | 3,459.5 | 10.5 | 6.8 | 0.0 | 60.0 | 21 | 14 | 4.0 | ||
hh_avg_income | 24,402,848.0 | 77,716.1 | 21,870.6 | 34,760.0 | 201,050.0 | 36 | 0 | 0.0 | ||
participation_rate | 22,327.9 | 67.9 | 9.3 | 35.7 | 89.8 | 21 | 0 | 0.0 | ||
university_degree_prevalance | 149.0 | 0.5 | 0.1 | 0.0 | 0.7 | 21 | 1 | 0.3 | ||
lone_parent_fam_prevalence | 60.1 | 0.2 | 0.1 | 0.0 | 0.6 | 20 | 0 | 0.0 | ||
home_owner_prevalence | 233.8 | 0.7 | 0.2 | 0.0 | 1.0 | 21 | 4 | 1.1 | ||
vandix | 156.6 | 0.5 | 0.7 | -1.0 | 3.4 | 36 | 0 | 0.0 | ||
ale_index | -387.8 | -1.3 | 0.6 | -2.1 | 0.0 | 56 | 0 | 0.0 | ||
canbics_index | 183.2 | 0.6 | 1.0 | 0.0 | 4.9 | 35 | 179 | 51.1 |
claims <- ggplot() +
geom_sf(data = north_central_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = north_central_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = north_central_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
north_central_sp <- as(north_central_sf, "Spatial")
north_central_sp$ui <- 1:nrow(north_central_sp@data)
coords <- coordinates(north_central_sp)
north_central_nb <- poly2nb(north_central_sp, queen = TRUE)
north_central_nb
## Neighbour list object:
## Number of regions: 350
## Number of nonzero links: 1934
## Percentage nonzero weights: 1.578776
## Average number of links: 5.525714
#assign nearest neighbour for no links
north_central_nb <- assign_nearest_neighbors(north_central_nb,north_central_sp)
plot(north_central_sp, border = grey(0.5))
plot(north_central_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(north_central_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(north_central_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: north_central_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 7.4904, p-value = 3.433e-14
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.234880440 -0.002865330 0.001007426
cyc_cc_mi <- moran.test(north_central_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: north_central_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 3.6381, p-value = 0.0001373
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.113990179 -0.002865330 0.001031689
pd_cc_mi <- moran.test(north_central_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: north_central_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 6.4778, p-value = 4.652e-11
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.1909270561 -0.0028653295 0.0008949772
nb2INLA("north_central.adj", north_central_nb)
g <- inla.read.graph(filename = "north_central.adj")
# Model Set 1: Total Casualty Claim Crashes
north_central_models_1 <- cma_models(north_central_sp@data, "North Central", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
north_central_all <- clean_fixed_effects(north_central_models_1$fixed_effects)
map(north_central_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.26, Running = 0.279, Post = 0.0786, Total = 0.617
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.385 0.099 1.188 1.386 1.576 1.386 0
## vandix_z 0.294 0.072 0.153 0.293 0.436 0.293 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.537 0.052 0.44 0.535 0.645 0.531
##
## Deviance Information Criterion (DIC) ...............: 1877.78
## Deviance Information Criterion (DIC, saturated) ....: 724.91
## Effective number of parameters .....................: 314.28
##
## Watanabe-Akaike information criterion (WAIC) ...: 1926.75
## Effective number of parameters .................: 245.94
##
## Marginal log-Likelihood: -1219.26
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.8, Running = 0.591, Post = 0.135, Total = 15.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.441 0.081 1.280 1.442 1.597 1.442 0
## vandix_z 0.166 0.074 0.021 0.166 0.312 0.166 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.308 0.048 0.224 0.305 0.412 0.298
## Phi for ui 0.774 0.067 0.624 0.781 0.886 0.796
##
## Deviance Information Criterion (DIC) ...............: 1836.90
## Deviance Information Criterion (DIC, saturated) ....: 684.03
## Effective number of parameters .....................: 299.06
##
## Watanabe-Akaike information criterion (WAIC) ...: 1859.14
## Effective number of parameters .................: 219.53
##
## Marginal log-Likelihood: -1102.65
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.2, Running = 0.587, Post = 0.166, Total = 16
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 0.699 0.134 0.433 0.700 0.960 0.700 0
## vandix_z 0.246 0.071 0.108 0.246 0.385 0.246 0
## ln_roads_km_c 0.656 0.093 0.474 0.656 0.839 0.656 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.236 0.033 0.175 0.234 0.304 0.233
## Phi for ui 0.943 0.034 0.856 0.950 0.987 0.965
##
## Deviance Information Criterion (DIC) ...............: 1798.49
## Deviance Information Criterion (DIC, saturated) ....: 645.62
## Effective number of parameters .....................: 282.37
##
## Watanabe-Akaike information criterion (WAIC) ...: 1793.36
## Effective number of parameters .................: 192.21
##
## Marginal log-Likelihood: -1084.45
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14.8, Running = 0.659, Post = 0.187, Total = 15.7
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) 1.197 0.224 0.754 1.197 1.634
## vandix_z 0.177 0.066 0.048 0.177 0.306
## ln_roads_km_c 0.497 0.089 0.321 0.497 0.672
## roads_prop_highway_arterial_z 0.631 0.086 0.463 0.631 0.800
## ale_index_z -0.204 0.294 -0.780 -0.204 0.375
## canbics_index_z 0.429 0.312 -0.183 0.429 1.040
## population_100_c 0.034 0.022 -0.007 0.034 0.077
## mode kld
## (Intercept) 1.197 0
## vandix_z 0.177 0
## ln_roads_km_c 0.497 0
## roads_prop_highway_arterial_z 0.631 0
## ale_index_z -0.204 0
## canbics_index_z 0.429 0
## population_100_c 0.034 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.276 0.037 0.208 0.275 0.354 0.274
## Phi for ui 0.955 0.031 0.876 0.962 0.992 0.977
##
## Deviance Information Criterion (DIC) ...............: 1791.38
## Deviance Information Criterion (DIC, saturated) ....: 638.51
## Effective number of parameters .....................: 272.89
##
## Watanabe-Akaike information criterion (WAIC) ...: 1779.75
## Effective number of parameters .................: 183.19
##
## Marginal log-Likelihood: -1080.19
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
north_central_models_2 <- cma_models(north_central_sp@data,"North Central","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
north_central_cyclist <- clean_fixed_effects(north_central_models_2$fixed_effects)
map(north_central_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.18, Running = 0.261, Post = 0.0718, Total = 0.513
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.097 0.178 -2.446 -2.097 -1.749 -2.097 0
## vandix_z 0.238 0.108 0.027 0.238 0.450 0.238 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 19896.21 19932.69 586.12 13845.55 73915.10 206.69
##
## Deviance Information Criterion (DIC) ...............: 342.46
## Deviance Information Criterion (DIC, saturated) ....: 261.09
## Effective number of parameters .....................: 1.98
##
## Watanabe-Akaike information criterion (WAIC) ...: 343.92
## Effective number of parameters .................: 3.40
##
## Marginal log-Likelihood: -176.09
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.4, Running = 0.619, Post = 0.144, Total = 15.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -3.068 0.343 -3.833 -3.049 -2.443 -3.056 0
## vandix_z 0.276 0.137 0.011 0.275 0.547 0.275 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.660 0.206 0.352 0.628 1.155 0.568
## Phi for ui 0.162 0.112 0.024 0.135 0.449 0.073
##
## Deviance Information Criterion (DIC) ...............: 276.93
## Deviance Information Criterion (DIC, saturated) ....: 195.56
## Effective number of parameters .....................: 52.45
##
## Watanabe-Akaike information criterion (WAIC) ...: 281.59
## Effective number of parameters .................: 43.08
##
## Marginal log-Likelihood: -80.58
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15, Running = 0.649, Post = 0.139, Total = 15.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -3.239 0.399 -4.089 -3.221 -2.504 -3.225 0
## vandix_z 0.307 0.143 0.029 0.306 0.591 0.306 0
## ln_roads_km_c 0.127 0.162 -0.188 0.125 0.449 0.125 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.647 0.202 0.344 0.615 1.133 0.556
## Phi for ui 0.195 0.128 0.031 0.165 0.516 0.093
##
## Deviance Information Criterion (DIC) ...............: 276.46
## Deviance Information Criterion (DIC, saturated) ....: 195.08
## Effective number of parameters .....................: 51.62
##
## Watanabe-Akaike information criterion (WAIC) ...: 281.36
## Effective number of parameters .................: 42.86
##
## Marginal log-Likelihood: -85.57
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14.9, Running = 0.826, Post = 0.204, Total = 16
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -2.309 0.496 -3.320 -2.296 -1.373
## vandix_z 0.304 0.145 0.022 0.303 0.593
## ln_roads_km_c 0.171 0.177 -0.174 0.170 0.521
## roads_prop_highway_arterial_z 0.522 0.195 0.141 0.520 0.908
## ale_index_z -0.216 0.711 -1.609 -0.217 1.184
## canbics_index_z 1.982 0.558 0.896 1.979 3.090
## population_100_c -0.072 0.080 -0.230 -0.072 0.085
## mode kld
## (Intercept) -2.297 0
## vandix_z 0.303 0
## ln_roads_km_c 0.170 0
## roads_prop_highway_arterial_z 0.520 0
## ale_index_z -0.217 0
## canbics_index_z 1.979 0
## population_100_c -0.072 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.890 0.339 0.417 0.827 1.731 0.714
## Phi for ui 0.288 0.162 0.055 0.260 0.663 0.173
##
## Deviance Information Criterion (DIC) ...............: 272.38
## Deviance Information Criterion (DIC, saturated) ....: 191.01
## Effective number of parameters .....................: 41.88
##
## Watanabe-Akaike information criterion (WAIC) ...: 280.15
## Effective number of parameters .................: 38.90
##
## Marginal log-Likelihood: -93.94
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
north_central_models_3 <- cma_models(north_central_sp@data,"North Central","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
north_central_pedestrian <- clean_fixed_effects(north_central_models_3$fixed_effects)
map(north_central_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.21, Running = 0.357, Post = 0.0769, Total = 0.644
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.974 0.225 -2.452 -1.962 -1.566 -1.928 0
## vandix_z 0.424 0.102 0.227 0.423 0.627 0.423 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.563 0.109 0.378 0.553 0.802 0.534
##
## Deviance Information Criterion (DIC) ...............: 613.58
## Deviance Information Criterion (DIC, saturated) ....: 380.61
## Effective number of parameters .....................: 132.57
##
## Watanabe-Akaike information criterion (WAIC) ...: 627.32
## Effective number of parameters .................: 102.18
##
## Marginal log-Likelihood: -350.09
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.7, Running = 0.606, Post = 0.141, Total = 15.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.865 0.195 -2.274 -1.857 -1.503 -1.858 0
## vandix_z 0.350 0.103 0.148 0.350 0.553 0.350 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.555 0.127 0.349 0.541 0.847 0.512
## Phi for ui 0.357 0.154 0.102 0.343 0.683 0.303
##
## Deviance Information Criterion (DIC) ...............: 589.79
## Deviance Information Criterion (DIC, saturated) ....: 356.82
## Effective number of parameters .....................: 113.83
##
## Watanabe-Akaike information criterion (WAIC) ...: 592.02
## Effective number of parameters .................: 84.15
##
## Marginal log-Likelihood: -257.75
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 14.8, Running = 0.681, Post = 0.21, Total = 15.7
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.945 0.242 -2.444 -1.938 -1.491 -1.938 0
## vandix_z 0.355 0.105 0.150 0.355 0.563 0.355 0
## ln_roads_km_c 0.071 0.140 -0.195 0.067 0.358 0.068 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.531 0.134 0.317 0.514 0.843 0.481
## Phi for ui 0.415 0.181 0.107 0.404 0.778 0.366
##
## Deviance Information Criterion (DIC) ...............: 588.24
## Deviance Information Criterion (DIC, saturated) ....: 355.27
## Effective number of parameters .....................: 112.40
##
## Watanabe-Akaike information criterion (WAIC) ...: 590.74
## Effective number of parameters .................: 83.54
##
## Marginal log-Likelihood: -263.12
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14.7, Running = 0.668, Post = 0.192, Total = 15.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -1.894 0.446 -2.803 -1.882 -1.052
## vandix_z 0.301 0.105 0.095 0.300 0.509
## ln_roads_km_c -0.097 0.160 -0.402 -0.100 0.228
## roads_prop_highway_arterial_z 0.659 0.146 0.375 0.658 0.946
## ale_index_z -1.045 0.632 -2.309 -1.037 0.173
## canbics_index_z 0.649 0.495 -0.317 0.646 1.629
## population_100_c 0.017 0.044 -0.069 0.017 0.105
## mode kld
## (Intercept) -1.883 0
## vandix_z 0.300 0
## ln_roads_km_c -0.100 0
## roads_prop_highway_arterial_z 0.658 0
## ale_index_z -1.037 0
## canbics_index_z 0.646 0
## population_100_c 0.017 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.546 0.155 0.303 0.525 0.909 0.486
## Phi for ui 0.528 0.188 0.170 0.532 0.865 0.547
##
## Deviance Information Criterion (DIC) ...............: 575.52
## Deviance Information Criterion (DIC, saturated) ....: 342.56
## Effective number of parameters .....................: 102.83
##
## Watanabe-Akaike information criterion (WAIC) ...: 578.07
## Effective number of parameters .................: 77.72
##
## Marginal log-Likelihood: -271.38
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
north_central_results <- bind_rows(north_central_all %>% mutate(Region = "North Central",Outcome = "All Injury Claims"),
north_central_cyclist %>% mutate(Region = "North Central",Outcome = "Cyclist Injury Claims"),
north_central_pedestrian %>% mutate(Region = "North Central",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Kamloops-Salmon Arm | n_claims | 204 | 24,765.0 | 121.4 | 244.3 | 0.0 | 2,286.0 | 0 | 5 | 2.5 |
n_casualty_claims | 4,069.0 | 19.9 | 39.5 | 0.0 | 293.0 | 0 | 19 | 9.3 | ||
n_cyclist_claims | 143.0 | 0.7 | 1.7 | 0.0 | 14.0 | 0 | 138 | 67.6 | ||
n_cyclist_casualty_claims | 89.0 | 0.4 | 1.1 | 0.0 | 10.0 | 0 | 152 | 74.5 | ||
n_pedestrian_claims | 236.0 | 1.2 | 2.9 | 0.0 | 21.0 | 0 | 130 | 63.7 | ||
n_pedestrian_casualty_claims | 183.0 | 0.9 | 2.3 | 0.0 | 17.0 | 0 | 137 | 67.2 | ||
population | 133,847.0 | 656.1 | 348.0 | 0.0 | 2,310.0 | 0 | 2 | 1.0 | ||
total_roads_km | 2,744.5 | 13.5 | 25.3 | 0.5 | 217.0 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 49.9 | 0.2 | 0.2 | 0.0 | 0.7 | 0 | 32 | 15.7 | ||
no_highschool_prevalance | 29.4 | 0.2 | 0.1 | 0.0 | 0.4 | 31 | 0 | 0.0 | ||
unemployment_rate | 1,439.0 | 8.3 | 5.3 | 0.0 | 37.5 | 31 | 12 | 5.9 | ||
hh_avg_income | 12,008,631.0 | 71,479.9 | 20,375.9 | 29,162.0 | 137,275.0 | 36 | 0 | 0.0 | ||
participation_rate | 10,775.2 | 62.3 | 9.9 | 30.6 | 90.0 | 31 | 0 | 0.0 | ||
university_degree_prevalance | 88.4 | 0.5 | 0.1 | 0.3 | 0.7 | 31 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 31.0 | 0.2 | 0.1 | 0.0 | 0.5 | 30 | 0 | 0.0 | ||
home_owner_prevalence | 128.1 | 0.7 | 0.2 | 0.1 | 1.0 | 31 | 0 | 0.0 | ||
vandix | 30.5 | 0.2 | 0.7 | -1.3 | 2.4 | 36 | 0 | 0.0 | ||
ale_index | -116.3 | -0.7 | 1.2 | -2.1 | 3.3 | 41 | 1 | 0.5 | ||
canbics_index | 227.8 | 1.4 | 1.5 | 0.0 | 5.6 | 41 | 40 | 19.6 |
claims <- ggplot() +
geom_sf(data = interior_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = interior_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = interior_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
interior_sp <- as(interior_sf, "Spatial")
interior_sp$ui <- 1:nrow(interior_sp@data)
coords <- coordinates(interior_sp)
interior_nb <- poly2nb(interior_sp, queen = TRUE)
## Warning in poly2nb(interior_sp, queen = TRUE): neighbour object has 3 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
interior_nb
## Neighbour list object:
## Number of regions: 204
## Number of nonzero links: 1098
## Percentage nonzero weights: 2.638408
## Average number of links: 5.382353
## 3 disjoint connected subgraphs
#assign nearest neighbour for no links
interior_nb <- assign_nearest_neighbors(interior_nb,interior_sp)
plot(interior_sp, border = grey(0.5))
plot(interior_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(interior_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(interior_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: interior_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 6.3114, p-value = 1.383e-10
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.261379586 -0.004926108 0.001780360
cyc_cc_mi <- moran.test(interior_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: interior_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 2.4815, p-value = 0.006542
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.096406801 -0.004926108 0.001667545
pd_cc_mi <- moran.test(interior_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: interior_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 4.6131, p-value = 1.983e-06
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.190275369 -0.004926108 0.001790493
nb2INLA("interior.adj", interior_nb)
g <- inla.read.graph(filename = "interior.adj")
# Model Set 1: Total Casualty Claim Crashes
interior_models_1 <- cma_models(interior_sp@data, "Kamloops-Salmon Arm", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
interior_all <- clean_fixed_effects(interior_models_1$fixed_effects)
map(interior_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.206, Running = 0.248, Post = 0.0771, Total = 0.531
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.936 0.105 1.728 1.937 2.139 1.937 0
## vandix_z 0.379 0.103 0.178 0.379 0.581 0.379 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.565 0.068 0.441 0.562 0.708 0.556
##
## Deviance Information Criterion (DIC) ...............: 1187.06
## Deviance Information Criterion (DIC, saturated) ....: 422.26
## Effective number of parameters .....................: 187.60
##
## Watanabe-Akaike information criterion (WAIC) ...: 1199.03
## Effective number of parameters .................: 136.48
##
## Marginal log-Likelihood: -796.51
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.7, Running = 0.509, Post = 0.131, Total = 15.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.953 0.082 1.790 1.954 2.112 1.954 0
## vandix_z 0.244 0.115 0.019 0.245 0.469 0.245 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.646 0.083 0.497 0.641 0.824 0.631
## Phi for ui 0.421 0.107 0.223 0.418 0.639 0.410
##
## Deviance Information Criterion (DIC) ...............: 1176.12
## Deviance Information Criterion (DIC, saturated) ....: 411.33
## Effective number of parameters .....................: 182.32
##
## Watanabe-Akaike information criterion (WAIC) ...: 1181.65
## Effective number of parameters .................: 129.27
##
## Marginal log-Likelihood: -647.10
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 14.6, Running = 0.521, Post = 0.179, Total = 15.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.431 0.099 1.235 1.432 1.625 1.432 0
## vandix_z 0.249 0.103 0.047 0.249 0.451 0.249 0
## ln_roads_km_c 0.850 0.106 0.643 0.849 1.059 0.849 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.773 0.104 0.588 0.767 0.996 0.756
## Phi for ui 0.627 0.097 0.427 0.632 0.804 0.639
##
## Deviance Information Criterion (DIC) ...............: 1158.32
## Deviance Information Criterion (DIC, saturated) ....: 393.52
## Effective number of parameters .....................: 172.42
##
## Watanabe-Akaike information criterion (WAIC) ...: 1151.71
## Effective number of parameters .................: 115.91
##
## Marginal log-Likelihood: -622.89
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 15, Running = 0.493, Post = 0.16, Total = 15.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) 1.134 0.119 0.900 1.134 1.368
## vandix_z 0.199 0.084 0.034 0.199 0.365
## ln_roads_km_c 0.492 0.097 0.303 0.492 0.682
## roads_prop_highway_arterial_z 0.535 0.056 0.425 0.535 0.646
## ale_index_z 0.092 0.257 -0.412 0.092 0.596
## canbics_index_z -0.709 0.249 -1.199 -0.708 -0.220
## population_100_c 0.099 0.019 0.062 0.099 0.135
## mode kld
## (Intercept) 1.134 0
## vandix_z 0.199 0
## ln_roads_km_c 0.492 0
## roads_prop_highway_arterial_z 0.535 0
## ale_index_z 0.092 0
## canbics_index_z -0.708 0
## population_100_c 0.099 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.17 0.170 0.867 1.161 1.534 1.145
## Phi for ui 0.82 0.085 0.622 0.833 0.948 0.864
##
## Deviance Information Criterion (DIC) ...............: 1138.19
## Deviance Information Criterion (DIC, saturated) ....: 373.39
## Effective number of parameters .....................: 154.83
##
## Watanabe-Akaike information criterion (WAIC) ...: 1123.47
## Effective number of parameters .................: 100.55
##
## Marginal log-Likelihood: -598.24
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
interior_models_2 <- cma_models(interior_sp@data,"Kamloops-Salmon Arm","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
interior_cyclist <- clean_fixed_effects(interior_models_2$fixed_effects)
map(interior_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.192, Running = 0.252, Post = 0.0682, Total = 0.512
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.703 0.241 -2.216 -1.690 -1.270 -1.653 0
## vandix_z 0.456 0.141 0.182 0.455 0.737 0.455 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.921 0.324 0.468 0.863 1.71 0.769
##
## Deviance Information Criterion (DIC) ...............: 324.99
## Deviance Information Criterion (DIC, saturated) ....: 204.25
## Effective number of parameters .....................: 56.16
##
## Watanabe-Akaike information criterion (WAIC) ...: 326.11
## Effective number of parameters .................: 43.18
##
## Marginal log-Likelihood: -187.90
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.7, Running = 0.519, Post = 0.103, Total = 15.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.615 0.208 -2.054 -1.608 -1.228 -1.609 0
## vandix_z 0.358 0.154 0.051 0.360 0.655 0.360 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.052 0.330 0.560 1.001 1.845 0.904
## Phi for ui 0.214 0.132 0.035 0.187 0.531 0.112
##
## Deviance Information Criterion (DIC) ...............: 323.34
## Deviance Information Criterion (DIC, saturated) ....: 202.60
## Effective number of parameters .....................: 50.44
##
## Watanabe-Akaike information criterion (WAIC) ...: 325.36
## Effective number of parameters .................: 40.43
##
## Marginal log-Likelihood: -58.61
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 14.4, Running = 0.508, Post = 0.118, Total = 15
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.039 0.278 -2.618 -2.029 -1.522 -2.030 0
## vandix_z 0.376 0.162 0.053 0.378 0.691 0.378 0
## ln_roads_km_c 0.585 0.201 0.198 0.582 0.991 0.582 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.053 0.343 0.546 0.998 1.880 0.896
## Phi for ui 0.523 0.194 0.162 0.525 0.874 0.522
##
## Deviance Information Criterion (DIC) ...............: 316.65
## Deviance Information Criterion (DIC, saturated) ....: 195.92
## Effective number of parameters .....................: 45.88
##
## Watanabe-Akaike information criterion (WAIC) ...: 318.61
## Effective number of parameters .................: 37.30
##
## Marginal log-Likelihood: -59.43
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14.4, Running = 0.492, Post = 0.143, Total = 15
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -1.916 0.325 -2.588 -1.904 -1.314
## vandix_z 0.372 0.176 0.017 0.376 0.706
## ln_roads_km_c 0.195 0.217 -0.225 0.193 0.626
## roads_prop_highway_arterial_z 0.399 0.138 0.130 0.399 0.673
## ale_index_z 0.639 0.489 -0.333 0.644 1.588
## canbics_index_z -0.277 0.491 -1.235 -0.280 0.693
## population_100_c 0.141 0.038 0.066 0.140 0.217
## mode kld
## (Intercept) -1.904 0
## vandix_z 0.376 0
## ln_roads_km_c 0.193 0
## roads_prop_highway_arterial_z 0.399 0
## ale_index_z 0.644 0
## canbics_index_z -0.280 0
## population_100_c 0.140 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.806 0.867 0.713 1.616 4.03 1.303
## Phi for ui 0.627 0.215 0.180 0.654 0.95 0.808
##
## Deviance Information Criterion (DIC) ...............: 308.18
## Deviance Information Criterion (DIC, saturated) ....: 187.44
## Effective number of parameters .....................: 34.53
##
## Watanabe-Akaike information criterion (WAIC) ...: 311.12
## Effective number of parameters .................: 30.56
##
## Marginal log-Likelihood: -66.39
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
interior_models_3 <- cma_models(interior_sp@data,"Kamloops-Salmon Arm","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
interior_pedestrian <- clean_fixed_effects(interior_models_3$fixed_effects)
map(interior_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.18, Running = 0.24, Post = 0.0535, Total = 0.473
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.597 0.248 -2.134 -1.581 -1.155 -1.544 0
## vandix_z 0.687 0.149 0.402 0.685 0.988 0.685 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.506 0.114 0.316 0.495 0.761 0.473
##
## Deviance Information Criterion (DIC) ...............: 421.56
## Deviance Information Criterion (DIC, saturated) ....: 250.11
## Effective number of parameters .....................: 92.33
##
## Watanabe-Akaike information criterion (WAIC) ...: 439.84
## Effective number of parameters .................: 75.38
##
## Marginal log-Likelihood: -251.71
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14, Running = 0.444, Post = 0.113, Total = 14.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.465 0.201 -1.888 -1.457 -1.092 -1.458 0
## vandix_z 0.649 0.159 0.340 0.648 0.964 0.648 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.625 0.133 0.404 0.611 0.923 0.586
## Phi for ui 0.271 0.125 0.077 0.254 0.552 0.211
##
## Deviance Information Criterion (DIC) ...............: 415.60
## Deviance Information Criterion (DIC, saturated) ....: 244.14
## Effective number of parameters .....................: 81.08
##
## Watanabe-Akaike information criterion (WAIC) ...: 423.72
## Effective number of parameters .................: 63.38
##
## Marginal log-Likelihood: -121.89
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 14.8, Running = 0.471, Post = 0.158, Total = 15.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.851 0.243 -2.351 -1.844 -1.395 -1.845 0
## vandix_z 0.685 0.161 0.371 0.684 1.002 0.684 0
## ln_roads_km_c 0.619 0.181 0.267 0.618 0.979 0.618 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.674 0.151 0.425 0.657 1.016 0.626
## Phi for ui 0.478 0.155 0.194 0.475 0.781 0.459
##
## Deviance Information Criterion (DIC) ...............: 408.89
## Deviance Information Criterion (DIC, saturated) ....: 237.43
## Effective number of parameters .....................: 73.23
##
## Watanabe-Akaike information criterion (WAIC) ...: 414.90
## Effective number of parameters .................: 57.59
##
## Marginal log-Likelihood: -121.52
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14.9, Running = 0.507, Post = 0.128, Total = 15.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -1.577 0.290 -2.171 -1.569 -1.034
## vandix_z 0.659 0.152 0.359 0.659 0.957
## ln_roads_km_c 0.245 0.189 -0.124 0.243 0.619
## roads_prop_highway_arterial_z 0.393 0.123 0.152 0.392 0.636
## ale_index_z 1.571 0.451 0.680 1.573 2.452
## canbics_index_z -0.979 0.452 -1.877 -0.976 -0.099
## population_100_c 0.111 0.037 0.039 0.111 0.184
## mode kld
## (Intercept) -1.569 0
## vandix_z 0.659 0
## ln_roads_km_c 0.243 0
## roads_prop_highway_arterial_z 0.392 0
## ale_index_z 1.573 0
## canbics_index_z -0.976 0
## population_100_c 0.111 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.084 0.314 0.602 1.039 1.826 0.953
## Phi for ui 0.379 0.197 0.067 0.359 0.786 0.264
##
## Deviance Information Criterion (DIC) ...............: 400.81
## Deviance Information Criterion (DIC, saturated) ....: 229.36
## Effective number of parameters .....................: 61.30
##
## Watanabe-Akaike information criterion (WAIC) ...: 404.56
## Effective number of parameters .................: 49.26
##
## Marginal log-Likelihood: -125.77
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
interior_results <- bind_rows(interior_all %>% mutate(Region = "Kamloops-Salmon Arm",Outcome = "All Injury Claims"),
interior_cyclist %>% mutate(Region = "Kamloops-Salmon Arm",Outcome = "Cyclist Injury Claims"),
interior_pedestrian %>% mutate(Region = "Kamloops-Salmon Arm",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Southeast | n_claims | 108 | 9,978.0 | 92.4 | 171.3 | 0.0 | 1,235.0 | 0 | 3 | 2.8 |
n_casualty_claims | 1,037.0 | 9.6 | 17.9 | 0.0 | 121.0 | 0 | 12 | 11.1 | ||
n_cyclist_claims | 40.0 | 0.4 | 0.8 | 0.0 | 4.0 | 0 | 85 | 78.7 | ||
n_cyclist_casualty_claims | 24.0 | 0.2 | 0.6 | 0.0 | 4.0 | 0 | 92 | 85.2 | ||
n_pedestrian_claims | 62.0 | 0.6 | 1.3 | 0.0 | 8.0 | 0 | 77 | 71.3 | ||
n_pedestrian_casualty_claims | 51.0 | 0.5 | 1.2 | 0.0 | 8.0 | 0 | 83 | 76.9 | ||
population | 60,427.0 | 559.5 | 202.6 | 0.0 | 1,482.0 | 0 | 2 | 1.9 | ||
total_roads_km | 1,598.6 | 14.8 | 23.9 | 1.3 | 202.4 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 13.9 | 0.1 | 0.2 | 0.0 | 0.5 | 0 | 49 | 45.4 | ||
no_highschool_prevalance | 16.2 | 0.2 | 0.1 | 0.0 | 0.3 | 4 | 0 | 0.0 | ||
unemployment_rate | 838.5 | 8.1 | 4.4 | 0.0 | 17.5 | 4 | 9 | 8.3 | ||
hh_avg_income | 7,149,722.0 | 68,747.3 | 16,755.0 | 34,159.0 | 122,980.0 | 4 | 0 | 0.0 | ||
participation_rate | 6,473.1 | 62.2 | 8.5 | 40.9 | 80.0 | 4 | 0 | 0.0 | ||
university_degree_prevalance | 57.1 | 0.5 | 0.1 | 0.3 | 0.7 | 4 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 17.1 | 0.2 | 0.1 | 0.0 | 0.4 | 4 | 0 | 0.0 | ||
home_owner_prevalence | 77.2 | 0.7 | 0.2 | 0.0 | 1.0 | 4 | 1 | 0.9 | ||
vandix | 8.2 | 0.1 | 0.6 | -0.9 | 1.6 | 4 | 0 | 0.0 | ||
ale_index | -125.7 | -1.2 | 0.7 | -2.1 | 0.4 | 7 | 0 | 0.0 | ||
canbics_index | 32.4 | 0.3 | 0.5 | 0.0 | 2.0 | 7 | 64 | 59.3 |
claims <- ggplot() +
geom_sf(data = southeast_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = southeast_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = southeast_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
southeast_sp <- as(southeast_sf, "Spatial")
southeast_sp$ui <- 1:nrow(southeast_sp@data)
coords <- coordinates(southeast_sp)
southeast_nb <- poly2nb(southeast_sp, queen = TRUE)
## Warning in poly2nb(southeast_sp, queen = TRUE): neighbour object has 3 sub-graphs;
## if this sub-graph count seems unexpected, try increasing the snap argument.
southeast_nb
## Neighbour list object:
## Number of regions: 108
## Number of nonzero links: 548
## Percentage nonzero weights: 4.698217
## Average number of links: 5.074074
## 3 disjoint connected subgraphs
#assign nearest neighbour for no links
southeast_nb <- assign_nearest_neighbors(southeast_nb,southeast_sp)
plot(southeast_sp, border = grey(0.5))
plot(southeast_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(southeast_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(southeast_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: southeast_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 2.6818, p-value = 0.003661
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.143726600 -0.009345794 0.003257898
cyc_cc_mi <- moran.test(southeast_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: southeast_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 0.61539, p-value = 0.2691
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.026276623 -0.009345794 0.003350726
pd_cc_mi <- moran.test(southeast_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: southeast_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 2.1151, p-value = 0.01721
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.111266178 -0.009345794 0.003251770
nb2INLA("southeast.adj", southeast_nb)
g <- inla.read.graph(filename = "southeast.adj")
# Model Set 1: Total Casualty Claim Crashes
southeast_models_1 <- cma_models(southeast_sp@data, "Southeast", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
southeast_all <- clean_fixed_effects(southeast_models_1$fixed_effects)
map(southeast_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.181, Running = 0.221, Post = 0.0696, Total = 0.472
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.313 0.135 1.041 1.315 1.571 1.315 0
## vandix_z 0.500 0.144 0.219 0.499 0.783 0.499 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.708 0.124 0.49 0.699 0.976 0.681
##
## Deviance Information Criterion (DIC) ...............: 544.56
## Deviance Information Criterion (DIC, saturated) ....: 208.25
## Effective number of parameters .....................: 90.53
##
## Watanabe-Akaike information criterion (WAIC) ...: 548.83
## Effective number of parameters .................: 65.15
##
## Marginal log-Likelihood: -352.71
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 15.2, Running = 0.347, Post = 0.138, Total = 15.7
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 1.317 0.110 1.096 1.319 1.529 1.318 0
## vandix_z 0.363 0.148 0.072 0.363 0.653 0.363 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.778 0.132 0.549 0.767 1.07 0.748
## Phi for ui 0.387 0.145 0.138 0.377 0.69 0.347
##
## Deviance Information Criterion (DIC) ...............: 540.42
## Deviance Information Criterion (DIC, saturated) ....: 204.12
## Effective number of parameters .....................: 88.58
##
## Watanabe-Akaike information criterion (WAIC) ...: 543.69
## Effective number of parameters .................: 63.22
##
## Marginal log-Likelihood: -264.51
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 14.9, Running = 0.37, Post = 0.135, Total = 15.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 0.761 0.165 0.435 0.762 1.082 0.762 0
## vandix_z 0.394 0.140 0.121 0.393 0.670 0.393 0
## ln_roads_km_c 0.707 0.160 0.396 0.706 1.024 0.706 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.855 0.151 0.593 0.843 1.185 0.822
## Phi for ui 0.643 0.152 0.326 0.655 0.897 0.686
##
## Deviance Information Criterion (DIC) ...............: 530.54
## Deviance Information Criterion (DIC, saturated) ....: 194.23
## Effective number of parameters .....................: 83.73
##
## Watanabe-Akaike information criterion (WAIC) ...: 527.56
## Effective number of parameters .................: 56.37
##
## Marginal log-Likelihood: -260.11
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14.8, Running = 0.39, Post = 0.173, Total = 15.4
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) 1.752 0.406 0.950 1.754 2.545
## vandix_z 0.367 0.131 0.112 0.367 0.626
## ln_roads_km_c 0.450 0.183 0.093 0.448 0.813
## roads_prop_highway_arterial_z 0.570 0.152 0.271 0.571 0.868
## ale_index_z 1.651 0.821 0.043 1.649 3.271
## canbics_index_z -0.567 0.854 -2.247 -0.566 1.108
## population_100_c 0.143 0.059 0.028 0.143 0.260
## mode kld
## (Intercept) 1.754 0
## vandix_z 0.367 0
## ln_roads_km_c 0.449 0
## roads_prop_highway_arterial_z 0.571 0
## ale_index_z 1.649 0
## canbics_index_z -0.567 0
## population_100_c 0.143 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.031 0.188 0.708 1.015 1.444 0.986
## Phi for ui 0.679 0.144 0.367 0.694 0.912 0.736
##
## Deviance Information Criterion (DIC) ...............: 526.65
## Deviance Information Criterion (DIC, saturated) ....: 190.34
## Effective number of parameters .....................: 80.38
##
## Watanabe-Akaike information criterion (WAIC) ...: 521.47
## Effective number of parameters .................: 53.13
##
## Marginal log-Likelihood: -268.71
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
southeast_models_2 <- cma_models(southeast_sp@data,"Southeast","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
southeast_cyclist <- clean_fixed_effects(southeast_models_2$fixed_effects)
map(southeast_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.193, Running = 0.258, Post = 0.057, Total = 0.508
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.762 0.244 -2.240 -1.762 -1.284 -1.762 0
## vandix_z 0.560 0.203 0.161 0.560 0.959 0.560 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 19965.61 19942.78 615.43 13915.78 73997.84 263.87
##
## Deviance Information Criterion (DIC) ...............: 130.22
## Deviance Information Criterion (DIC, saturated) ....: 93.75
## Effective number of parameters .....................: 1.97
##
## Watanabe-Akaike information criterion (WAIC) ...: 130.74
## Effective number of parameters .................: 2.42
##
## Marginal log-Likelihood: -68.93
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.8, Running = 0.372, Post = 0.132, Total = 15.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.985 0.351 -2.765 -1.955 -1.375 -1.903 0
## vandix_z 0.601 0.231 0.158 0.597 1.069 0.597 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 12.678 37.455 0.779 4.312 78.077 1.436
## Phi for ui 0.293 0.228 0.018 0.233 0.826 0.045
##
## Deviance Information Criterion (DIC) ...............: 124.27
## Deviance Information Criterion (DIC, saturated) ....: 87.80
## Effective number of parameters .....................: 9.36
##
## Watanabe-Akaike information criterion (WAIC) ...: 132.28
## Effective number of parameters .................: 15.04
##
## Marginal log-Likelihood: 11.10
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 15.2, Running = 0.422, Post = 0.124, Total = 15.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.423 0.438 -3.340 -2.405 -1.612 -2.406 0
## vandix_z 0.748 0.249 0.264 0.746 1.244 0.746 0
## ln_roads_km_c 0.444 0.244 -0.034 0.443 0.926 0.443 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 56.460 364.636 0.765 7.786 382.821 1.522
## Phi for ui 0.361 0.247 0.028 0.314 0.881 0.081
##
## Deviance Information Criterion (DIC) ...............: 123.57
## Deviance Information Criterion (DIC, saturated) ....: 87.10
## Effective number of parameters .....................: 9.93
##
## Watanabe-Akaike information criterion (WAIC) ...: 128.08
## Effective number of parameters .................: 12.62
##
## Marginal log-Likelihood: 8.21
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14, Running = 0.353, Post = 0.124, Total = 14.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -0.837 0.613 -2.054 -0.833 0.351
## vandix_z 0.822 0.252 0.331 0.821 1.318
## ln_roads_km_c 0.197 0.374 -0.536 0.197 0.930
## roads_prop_highway_arterial_z 0.315 0.333 -0.335 0.314 0.970
## ale_index_z 1.874 1.367 -0.795 1.869 4.570
## canbics_index_z 0.194 1.303 -2.362 0.194 2.750
## population_100_c 0.276 0.095 0.090 0.276 0.464
## mode kld
## (Intercept) -0.834 0
## vandix_z 0.821 0
## ln_roads_km_c 0.197 0
## roads_prop_highway_arterial_z 0.314 0
## ale_index_z 1.870 0
## canbics_index_z 0.194 0
## population_100_c 0.276 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 8350.731 2.26e+05 0.919 69.312 2.86e+04 0.935
## Phi for ui 0.356 2.63e-01 0.019 0.297 9.06e-01 0.043
##
## Deviance Information Criterion (DIC) ...............: 120.52
## Deviance Information Criterion (DIC, saturated) ....: 84.06
## Effective number of parameters .....................: 8.01
##
## Watanabe-Akaike information criterion (WAIC) ...: 124.56
## Effective number of parameters .................: 10.46
##
## Marginal log-Likelihood: -1.92
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
southeast_models_3 <- cma_models(southeast_sp@data,"Southeast","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
southeast_pedestrian <- clean_fixed_effects(southeast_models_3$fixed_effects)
map(southeast_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.163, Running = 0.225, Post = 0.0685, Total = 0.456
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.131 0.446 -3.145 -2.083 -1.405 -2.025 0.010
## vandix_z 0.616 0.276 0.093 0.617 1.149 0.610 0.006
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.529 0.206 0.233 0.494 1.03 0.434
##
## Deviance Information Criterion (DIC) ...............: 170.46
## Deviance Information Criterion (DIC, saturated) ....: 110.33
## Effective number of parameters .....................: 39.29
##
## Watanabe-Akaike information criterion (WAIC) ...: 191.49
## Effective number of parameters .................: 39.30
##
## Marginal log-Likelihood: -106.80
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.8, Running = 0.379, Post = 0.133, Total = 15.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.838 0.317 -2.525 -1.822 -1.262 -1.778 0
## vandix_z 0.529 0.240 0.060 0.528 1.004 0.528 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.734 0.246 0.370 0.695 1.325 0.623
## Phi for ui 0.176 0.148 0.013 0.132 0.565 0.035
##
## Deviance Information Criterion (DIC) ...............: 167.16
## Deviance Information Criterion (DIC, saturated) ....: 106.98
## Effective number of parameters .....................: 32.57
##
## Watanabe-Akaike information criterion (WAIC) ...: 170.59
## Effective number of parameters .................: 26.06
##
## Marginal log-Likelihood: -24.37
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 14.6, Running = 0.377, Post = 0.134, Total = 15.1
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.056 0.378 -2.852 -2.040 -1.358 -2.041 0
## vandix_z 0.574 0.246 0.091 0.573 1.059 0.573 0
## ln_roads_km_c 0.267 0.259 -0.242 0.267 0.779 0.267 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.753 0.260 0.372 0.710 1.382 0.632
## Phi for ui 0.214 0.171 0.016 0.166 0.647 0.044
##
## Deviance Information Criterion (DIC) ...............: 168.33
## Deviance Information Criterion (DIC, saturated) ....: 108.15
## Effective number of parameters .....................: 32.48
##
## Watanabe-Akaike information criterion (WAIC) ...: 172.48
## Effective number of parameters .................: 26.56
##
## Marginal log-Likelihood: -28.68
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14.7, Running = 0.397, Post = 0.156, Total = 15.3
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -1.262 0.802 -2.886 -1.246 0.272
## vandix_z 0.581 0.253 0.085 0.581 1.082
## ln_roads_km_c -0.061 0.387 -0.829 -0.059 0.693
## roads_prop_highway_arterial_z 0.297 0.332 -0.359 0.298 0.948
## ale_index_z 0.576 1.430 -2.258 0.584 3.368
## canbics_index_z 0.058 1.490 -2.834 0.044 3.032
## population_100_c 0.213 0.118 -0.015 0.212 0.448
## mode kld
## (Intercept) -1.247 0
## vandix_z 0.581 0
## ln_roads_km_c -0.059 0
## roads_prop_highway_arterial_z 0.298 0
## ale_index_z 0.584 0
## canbics_index_z 0.044 0
## population_100_c 0.212 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.728 0.266 0.346 0.683 1.376 0.600
## Phi for ui 0.241 0.184 0.019 0.193 0.695 0.054
##
## Deviance Information Criterion (DIC) ...............: 169.90
## Deviance Information Criterion (DIC, saturated) ....: 109.71
## Effective number of parameters .....................: 33.91
##
## Watanabe-Akaike information criterion (WAIC) ...: 177.56
## Effective number of parameters .................: 29.59
##
## Marginal log-Likelihood: -43.62
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
southeast_results <- bind_rows(southeast_all %>% mutate(Region = "Southeast",Outcome = "All Injury Claims"),
southeast_cyclist %>% mutate(Region = "Southeast",Outcome = "Cyclist Injury Claims"),
southeast_pedestrian %>% mutate(Region = "Southeast",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
region | variable | n | sum | mean | sd | min | max | missing | n_zero | p_zero |
|---|---|---|---|---|---|---|---|---|---|---|
Northwest | n_claims | 75 | 4,580.0 | 61.1 | 107.4 | 0.0 | 746.0 | 0 | 3 | 4.0 |
n_casualty_claims | 498.0 | 6.6 | 12.0 | 0.0 | 67.0 | 0 | 14 | 18.7 | ||
n_cyclist_claims | 18.0 | 0.2 | 0.7 | 0.0 | 3.0 | 0 | 64 | 85.3 | ||
n_cyclist_casualty_claims | 9.0 | 0.1 | 0.4 | 0.0 | 2.0 | 0 | 67 | 89.3 | ||
n_pedestrian_claims | 51.0 | 0.7 | 1.2 | 0.0 | 5.0 | 0 | 51 | 68.0 | ||
n_pedestrian_casualty_claims | 41.0 | 0.5 | 1.1 | 0.0 | 5.0 | 0 | 54 | 72.0 | ||
population | 32,421.0 | 432.3 | 138.7 | 0.0 | 747.0 | 0 | 1 | 1.3 | ||
total_roads_km | 1,124.4 | 15.0 | 30.2 | 0.9 | 151.7 | 0 | 0 | 0.0 | ||
roads_prop_highway_arterial | 11.7 | 0.2 | 0.2 | 0.0 | 1.0 | 0 | 36 | 48.0 | ||
no_highschool_prevalance | 17.4 | 0.2 | 0.1 | 0.1 | 0.5 | 2 | 0 | 0.0 | ||
unemployment_rate | 856.2 | 11.7 | 8.1 | 0.0 | 44.4 | 2 | 4 | 5.3 | ||
hh_avg_income | 5,317,156.0 | 74,889.5 | 16,545.8 | 43,382.0 | 115,632.0 | 4 | 0 | 0.0 | ||
participation_rate | 4,990.6 | 68.4 | 6.6 | 50.0 | 81.4 | 2 | 0 | 0.0 | ||
university_degree_prevalance | 33.9 | 0.5 | 0.1 | 0.2 | 0.6 | 2 | 0 | 0.0 | ||
lone_parent_fam_prevalence | 14.1 | 0.2 | 0.1 | 0.0 | 0.4 | 2 | 0 | 0.0 | ||
home_owner_prevalence | 50.9 | 0.7 | 0.2 | 0.2 | 1.0 | 2 | 0 | 0.0 | ||
vandix | 45.3 | 0.6 | 0.9 | -0.7 | 3.4 | 4 | 0 | 0.0 | ||
ale_index | -106.5 | -1.5 | 0.5 | -2.1 | -0.5 | 3 | 0 | 0.0 | ||
canbics_index | 0.0 | 0.0 | 0.0 | 0.0 | 0.0 | 2 | 73 | 97.3 |
claims <- ggplot() +
geom_sf(data = northwest_sf, aes(fill = n_casualty_claims,colour=n_casualty_claims)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Insurance Claims",
type = "aggregation", palette = "Earth", direction = -1) +
theme_void() +
ggtitle(
"Vancouver"
)
vandix <- ggplot() +
geom_sf(data = northwest_sf, aes(fill = vandix_z_c,colour=vandix_z_c)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
scale_colour_carto_d(name = "VanDIX Score ",
type = "diverging", palette = "Earth", direction = -1) +
theme_void()
total_roads <- ggplot() +
geom_sf(data = northwest_sf, aes(fill = total_roads_km,colour=total_roads_km)) +
coord_sf(crs = "+proj=utm +zone=10 +datum=NAD83 +units=m +no_defs") +
scale_fill_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
scale_colour_carto_c(name = "Kilometres of Road",
type = "quantitative", palette = "Earth", direction = -1) +
theme_void()
cowplot::plot_grid(claims,vandix,total_roads,ncol=1)
#### Define Spatial Neighrbourhoods
northwest_sp <- as(northwest_sf, "Spatial")
northwest_sp$ui <- 1:nrow(northwest_sp@data)
coords <- coordinates(northwest_sp)
northwest_nb <- poly2nb(northwest_sp, queen = TRUE)
northwest_nb
## Neighbour list object:
## Number of regions: 75
## Number of nonzero links: 400
## Percentage nonzero weights: 7.111111
## Average number of links: 5.333333
#assign nearest neighbour for no links
northwest_nb <- assign_nearest_neighbors(northwest_nb,northwest_sp)
plot(northwest_sp, border = grey(0.5))
plot(northwest_nb,
coords = coords,
add = TRUE, pch = 16, lwd = 2)
listw <- nb2listw(northwest_nb,zero.policy = TRUE)
all_cc_mi <- moran.test(northwest_sf$n_casualty_claims, listw,zero.policy = TRUE)
all_cc_mi
##
## Moran I test under randomisation
##
## data: northwest_sf$n_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 4.4875, p-value = 3.604e-06
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.278584187 -0.013513514 0.004236974
cyc_cc_mi <- moran.test(northwest_sf$n_cyclist_casualty_claims, listw,zero.policy = TRUE)
cyc_cc_mi
##
## Moran I test under randomisation
##
## data: northwest_sf$n_cyclist_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 1.1222, p-value = 0.1309
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.061319124 -0.013513514 0.004446537
pd_cc_mi <- moran.test(northwest_sf$n_pedestrian_casualty_claims, listw,zero.policy = TRUE)
pd_cc_mi
##
## Moran I test under randomisation
##
## data: northwest_sf$n_pedestrian_casualty_claims
## weights: listw
##
## Moran I statistic standard deviate = 4.3514, p-value = 6.764e-06
## alternative hypothesis: greater
## sample estimates:
## Moran I statistic Expectation Variance
## 0.288989227 -0.013513514 0.004832834
nb2INLA("northwest.adj", northwest_nb)
g <- inla.read.graph(filename = "northwest.adj")
# Model Set 1: Total Casualty Claim Crashes
northwest_models_1 <- cma_models(northwest_sp@data, "Northwest", "n_casualty_claims", "vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
northwest_all <- clean_fixed_effects(northwest_models_1$fixed_effects)
map(northwest_models_1$models, ~ summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.205, Running = 0.216, Post = 0.0613, Total = 0.482
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 0.693 0.216 0.252 0.699 1.101 0.699 0
## vandix_z 0.344 0.121 0.109 0.343 0.586 0.343 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.694 0.159 0.428 0.679 1.05 0.65
##
## Deviance Information Criterion (DIC) ...............: 347.02
## Deviance Information Criterion (DIC, saturated) ....: 143.51
## Effective number of parameters .....................: 59.57
##
## Watanabe-Akaike information criterion (WAIC) ...: 352.20
## Effective number of parameters .................: 44.57
##
## Marginal log-Likelihood: -227.05
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.1, Running = 0.328, Post = 0.14, Total = 14.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 0.728 0.200 0.321 0.733 1.106 0.733 0
## vandix_z 0.338 0.119 0.106 0.338 0.574 0.338 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.759 0.171 0.480 0.741 1.148 0.704
## Phi for ui 0.162 0.164 0.004 0.102 0.611 0.007
##
## Deviance Information Criterion (DIC) ...............: 349.00
## Deviance Information Criterion (DIC, saturated) ....: 145.49
## Effective number of parameters .....................: 59.26
##
## Watanabe-Akaike information criterion (WAIC) ...: 355.39
## Effective number of parameters .................: 45.31
##
## Marginal log-Likelihood: -186.79
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 13.5, Running = 0.341, Post = 0.131, Total = 13.9
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) 0.308 0.215 -0.125 0.312 0.719 0.311 0
## vandix_z 0.388 0.117 0.162 0.387 0.621 0.387 0
## ln_roads_km_c 0.688 0.169 0.354 0.688 1.020 0.689 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 0.678 0.191 0.375 0.654 1.119 0.610
## Phi for ui 0.651 0.212 0.195 0.685 0.957 0.846
##
## Deviance Information Criterion (DIC) ...............: 338.58
## Deviance Information Criterion (DIC, saturated) ....: 135.07
## Effective number of parameters .....................: 54.79
##
## Watanabe-Akaike information criterion (WAIC) ...: 339.42
## Effective number of parameters .................: 38.99
##
## Marginal log-Likelihood: -184.39
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 13.6, Running = 0.346, Post = 0.114, Total = 14
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -4.533 10.107 -24.606 -4.185 13.837
## vandix_z 0.274 0.107 0.067 0.274 0.483
## ln_roads_km_c 0.376 0.296 -0.166 0.368 0.939
## roads_prop_highway_arterial_z 0.241 0.215 -0.183 0.241 0.665
## ale_index_z 3.285 0.886 1.540 3.286 5.024
## canbics_index_z -8.760 11.642 -30.041 -9.146 14.587
## population_100_c 0.406 0.120 0.172 0.406 0.641
## mode kld
## (Intercept) -4.415 0.000
## vandix_z 0.264 0.183
## ln_roads_km_c 0.385 0.037
## roads_prop_highway_arterial_z 0.203 1.076
## ale_index_z 3.389 0.359
## canbics_index_z -8.912 0.000
## population_100_c 0.422 0.509
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.247 0.293 0.766 1.214 1.914 1.153
## Phi for ui 0.121 0.145 0.003 0.064 0.553 0.005
##
## Deviance Information Criterion (DIC) ...............: -1.35e+18
## Deviance Information Criterion (DIC, saturated) ....: -1.35e+18
## Effective number of parameters .....................: -1.35e+18
##
## Watanabe-Akaike information criterion (WAIC) ...: 237747.15
## Effective number of parameters .................: 118741.79
##
## Marginal log-Likelihood: -185.74
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 2: Total Casualty Cyclist Claim Crashes
northwest_models_2 <- cma_models(northwest_sp@data,"Northwest","n_cyclist_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
northwest_cyclist <- clean_fixed_effects(northwest_models_2$fixed_effects)
map(northwest_models_2$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.191, Running = 0.209, Post = 0.0609, Total = 0.461
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.579 0.480 -3.519 -2.579 -1.638 -2.579 0
## vandix_z 0.279 0.218 -0.149 0.279 0.707 0.279 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 19994.34 19947.32 627.83 13945.10 74031.50 274.65
##
## Deviance Information Criterion (DIC) ...............: 59.78
## Deviance Information Criterion (DIC, saturated) ....: 43.07
## Effective number of parameters .....................: 1.92
##
## Watanabe-Akaike information criterion (WAIC) ...: 59.97
## Effective number of parameters .................: 1.95
##
## Marginal log-Likelihood: -33.15
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 14.2, Running = 0.294, Post = 0.136, Total = 14.6
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.606 0.484 -3.558 -2.605 -1.658 -2.605 0
## vandix_z 0.282 0.220 -0.150 0.282 0.715 0.282 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1257.688 14184.56 2.356 85.806 7909.690 3.599
## Phi for ui 0.341 0.28 0.009 0.264 0.927 0.011
##
## Deviance Information Criterion (DIC) ...............: 59.70
## Deviance Information Criterion (DIC, saturated) ....: 42.99
## Effective number of parameters .....................: 2.28
##
## Watanabe-Akaike information criterion (WAIC) ...: 59.92
## Effective number of parameters .................: 2.42
##
## Marginal log-Likelihood: 4.29
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 14.2, Running = 0.3, Post = 0.149, Total = 14.7
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -2.657 0.542 -3.723 -2.657 -1.596 -2.657 0
## vandix_z 0.291 0.230 -0.160 0.291 0.743 0.291 0
## ln_roads_km_c -0.058 0.357 -0.757 -0.058 0.642 -0.058 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1276.40 1.46e+04 2.320 85.232 7995.673 3.528
## Phi for ui 0.34 2.81e-01 0.009 0.264 0.927 0.011
##
## Deviance Information Criterion (DIC) ...............: 61.64
## Deviance Information Criterion (DIC, saturated) ....: 44.93
## Effective number of parameters .....................: 3.17
##
## Watanabe-Akaike information criterion (WAIC) ...: 62.01
## Effective number of parameters .................: 3.33
##
## Marginal log-Likelihood: -0.191
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 14, Running = 0.337, Post = 0.198, Total = 14.5
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -38.517 37.252 -109.947 -35.376 13.733
## vandix_z -0.019 0.346 -0.853 0.011 0.574
## ln_roads_km_c -1.659 1.668 -5.446 -1.128 0.494
## roads_prop_highway_arterial_z 0.788 0.706 -0.620 0.789 2.191
## ale_index_z 3.288 3.457 -4.596 3.336 10.010
## canbics_index_z -45.597 43.289 -128.707 -40.491 14.788
## population_100_c 0.804 0.573 -0.032 0.675 2.157
## mode kld
## (Intercept) -4.198 0.000
## vandix_z 0.054 0.000
## ln_roads_km_c -0.858 0.001
## roads_prop_highway_arterial_z 0.789 0.000
## ale_index_z 3.273 0.000
## canbics_index_z -5.864 0.000
## population_100_c 0.543 0.000
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1375.819 1.62e+04 2.382 86.967 8522.574 3.671
## Phi for ui 0.341 2.81e-01 0.009 0.264 0.927 0.011
##
## Deviance Information Criterion (DIC) ...............: 102.80
## Deviance Information Criterion (DIC, saturated) ....: 86.09
## Effective number of parameters .....................: 23.20
##
## Watanabe-Akaike information criterion (WAIC) ...: 708.61
## Effective number of parameters .................: 328.06
##
## Marginal log-Likelihood: -9.88
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
# Model Set 3: Total Casualty Cyclist Claim Crashes
northwest_models_3 <- cma_models(northwest_sp@data,"Northwest","n_pedestrian_casualty_claims","vandix_z")
## [1] "Fit unadjusted non-spatial"
## [1] "Fit unadjusted"
## [1] "Fit adjusted by road length"
## [1] "Fit adjusted by road length and covariates"
northwest_pedestrian <- clean_fixed_effects(northwest_models_3$fixed_effects)
map(northwest_models_3$models,~summary(.x))
## $Nonspatial
## Time used:
## Pre = 0.216, Running = 0.211, Post = 0.054, Total = 0.481
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.054 0.229 -1.503 -1.054 -0.606 -1.054 0
## vandix_z 0.330 0.101 0.132 0.330 0.528 0.330 0
##
## Random effects:
## Name Model
## ui IID model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 19915.13 19935.61 594.13 13864.63 73936.99 223.84
##
## Deviance Information Criterion (DIC) ...............: 162.75
## Deviance Information Criterion (DIC, saturated) ....: 110.89
## Effective number of parameters .....................: 1.98
##
## Watanabe-Akaike information criterion (WAIC) ...: 164.64
## Effective number of parameters .................: 3.59
##
## Marginal log-Likelihood: -86.16
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Unadjusted
## Time used:
## Pre = 13.4, Running = 0.329, Post = 0.112, Total = 13.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.430 0.345 -2.169 -1.411 -0.810 -1.360 0
## vandix_z 0.309 0.147 0.023 0.307 0.605 0.307 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.765 1.098 0.557 1.486 4.667 1.083
## Phi for ui 0.303 0.224 0.021 0.249 0.817 0.058
##
## Deviance Information Criterion (DIC) ...............: 140.66
## Deviance Information Criterion (DIC, saturated) ....: 88.80
## Effective number of parameters .....................: 18.53
##
## Watanabe-Akaike information criterion (WAIC) ...: 145.84
## Effective number of parameters .................: 18.51
##
## Marginal log-Likelihood: -45.69
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted1
## Time used:
## Pre = 13.3, Running = 0.328, Post = 0.544, Total = 14.2
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant mode kld
## (Intercept) -1.612 0.397 -2.457 -1.592 -0.890 -1.534 0
## vandix_z 0.333 0.154 0.035 0.331 0.642 0.331 0
## ln_roads_km_c 0.207 0.234 -0.242 0.203 0.680 0.203 0
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 1.582 0.958 0.507 1.341 4.11 0.989
## Phi for ui 0.387 0.249 0.033 0.349 0.89 0.103
##
## Deviance Information Criterion (DIC) ...............: 139.92
## Deviance Information Criterion (DIC, saturated) ....: 88.06
## Effective number of parameters .....................: 19.74
##
## Watanabe-Akaike information criterion (WAIC) ...: 144.56
## Effective number of parameters .................: 18.85
##
## Marginal log-Likelihood: -50.22
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
##
##
## $Adjusted2
## Time used:
## Pre = 13.3, Running = 0.354, Post = 0.12, Total = 13.8
## Fixed effects:
## mean sd 0.025quant 0.5quant 0.975quant
## (Intercept) -19.299 32.477 -99.203 -7.360 14.678
## vandix_z 0.413 0.838 -0.160 0.228 3.463
## ln_roads_km_c -0.580 2.448 -9.532 0.037 0.999
## roads_prop_highway_arterial_z 0.788 1.741 -0.446 0.333 7.202
## ale_index_z 6.223 7.345 1.132 4.180 32.923
## canbics_index_z -20.333 29.636 -101.264 -11.251 14.317
## population_100_c 0.324 0.724 -1.856 0.350 2.077
## mode kld
## (Intercept) -4.269 0.000
## vandix_z 0.215 0.000
## ln_roads_km_c 0.023 0.001
## roads_prop_highway_arterial_z 0.344 0.000
## ale_index_z 4.305 0.000
## canbics_index_z -6.957 0.000
## population_100_c 0.328 0.000
##
## Random effects:
## Name Model
## ui BYM2 model
##
## Model hyperparameters:
## mean sd 0.025quant 0.5quant 0.975quant mode
## Precision for ui 2.401 1.812 0.625 1.90 7.233 1.268
## Phi for ui 0.285 0.216 0.019 0.23 0.794 0.052
##
## Deviance Information Criterion (DIC) ...............: -6.59e+24
## Deviance Information Criterion (DIC, saturated) ....: -6.59e+24
## Effective number of parameters .....................: -6.59e+24
##
## Watanabe-Akaike information criterion (WAIC) ...: 38338.17
## Effective number of parameters .................: 19113.96
##
## Marginal log-Likelihood: -57.38
## CPO, PIT is computed
## Posterior summaries for the linear predictor and the fitted values are computed
## (Posterior marginals needs also 'control.compute=list(return.marginals.predictor=TRUE)')
northwest_results <- bind_rows(northwest_all %>% mutate(Region = "Northwest",Outcome = "All Injury Claims"),
northwest_cyclist %>% mutate(Region = "Northwest",Outcome = "Cyclist Injury Claims"),
northwest_pedestrian %>% mutate(Region = "Northwest",Outcome = "Pedestrian Injury Claims")
) %>%
filter(variable == "vandix_z") %>%
select(Region,Outcome,everything())
beepr::beep(8)
## Downloading: 3.6 kB Downloading: 3.6 kB Downloading: 3.6 kB Downloading: 3.6 kB Downloading: 3.6 kB Downloading: 3.6 kB Downloading: 20 kB Downloading: 20 kB Downloading: 24 kB Downloading: 24 kB Downloading: 24 kB Downloading: 24 kB
Regional Grouping of Census Metropolitan and Agglomeration Areas. Labelled Points Represent Census Metroplitan Area and Census Agglomeration Centroids
Number of DAs | population_mean | Population (%) | Total Roads (km) (%) | Percentage of Major Roads (SD) | Total Injury Claims (%) | Injury Claims Mean (SD) | Total Cycling Injury Claims (%) | Cycling Injury Claims Mean (SD) | Total Pedestrian Injury Claims (%) | Pedestrian Injury Claims Mean (SD) | VANDIX Mean (SD) | No Highschool Prevalence Mean (SD) | Unemployment Rate Mean (SD) | Average Household Income Mean (SD) | Participation Rate Mean (SD) | University Degree Prevalence Mean (SD) | Lone Parent Family Prevalence Mean (SD) | Home Ownership Prevalence Mean (SD) | ALE Index Mean (SD) | CANBICS Index Mean (SD) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
6,473 | 691.9711 | 4,477,053 (100%) | 47,866 (100%) | 14.6 (17.4) | 211,852 (100%) | 32.7 (71) | 7,287 (100%) | 1.13 (2.77) | 10,531 (100%) | 1.63 (3.46) | -0.017 (0.64) | 0.157 (0.0802) | 6.73 (4.57) | 80100 (30400) | 63.8 (10.9) | 0.547 (0.118) | 0.16 (0.0787) | 0.691 (0.222) | 0.693 (3.07) | 3.15 (3.65) |
The analysis included 6473 dissemination areas across 20 different metropolitan regions with a total of 211852 motor-vehicle crashes resulting in at least one injury, and 7287 such crashes involved at least one cyclist, while 10531 involved at least one pedestrian.
region_name | Number of DAs | Population (%) | Total Roads (km) (%) | Percentage of Major Roads (SD) | Total Injury Claims (%) | Injury Claims Mean (SD) | Total Cycling Injury Claims (%) | Cycling Injury Claims Mean (SD) | Total Pedestrian Injury Claims (%) | Pedestrian Injury Claims Mean (SD) | VANDIX Mean (SD) | No Highschool Prevalence Mean (SD) | Unemployment Rate Mean (SD) | Average Household Income Mean (SD) | Participation Rate Mean (SD) | University Degree Prevalence Mean (SD) | Lone Parent Family Prevalence Mean (SD) | Home Ownership Prevalence Mean (SD) | ALE Index Mean (SD) | CANBICS Index Mean (SD) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Vancouver-Squamish | 3,620 | 2,667,057 (59.6%) | 15,057 (31.5%) | 15.9 (18.4) | 149,692 (70.7%) | 41.4 (84.8) | 4,968 (68.2%) | 1.37 (3.24) | 7,502 (71.2%) | 2.07 (4.02) | -0.14 (0.58) | 0.143 (0.0767) | 5.88 (3.58) | 85400 (34200) | 64.9 (10.1) | 0.569 (0.121) | 0.155 (0.0659) | 0.671 (0.23) | 1.63 (3.58) | 4.57 (4.11) |
Victoria | 579 | 397,237 (8.87%) | 3,262 (6.81%) | 11.6 (14) | 12,338 (5.82%) | 21.3 (34.3) | 1,027 (14.1%) | 1.77 (3.18) | 715 (6.79%) | 1.23 (2.54) | -0.24 (0.52) | 0.121 (0.0581) | 5.63 (3.87) | 77300 (26900) | 63.6 (11.1) | 0.597 (0.0978) | 0.153 (0.08) | 0.654 (0.231) | 0.607 (1.78) | 2.12 (1.71) |
Central Island-Powell River | 601 | 357,163 (7.98%) | 5,653 (11.8%) | 13 (16.1) | 10,762 (5.08%) | 17.9 (28.4) | 271 (3.72%) | 0.451 (0.944) | 547 (5.19%) | 0.91 (1.97) | 0.2 (0.65) | 0.177 (0.0756) | 8.35 (5.15) | 65700 (17200) | 56.5 (11) | 0.524 (0.0938) | 0.167 (0.0948) | 0.744 (0.188) | -1.07 (0.719) | 0.588 (0.914) |
Okanagan | 464 | 336,628 (7.52%) | 4,760 (9.94%) | 13 (16.2) | 13,236 (6.25%) | 28.5 (66.7) | 485 (6.66%) | 1.05 (2.34) | 564 (5.36%) | 1.22 (3.24) | 0.12 (0.6) | 0.164 (0.0651) | 7.76 (4.73) | 73000 (26800) | 61.3 (12.9) | 0.527 (0.0836) | 0.158 (0.0831) | 0.728 (0.208) | -0.843 (0.959) | 1.9 (1.81) |
Fraser Valley | 472 | 309,493 (6.91%) | 3,679 (7.69%) | 8.58 (13.8) | 15,730 (7.42%) | 33.3 (65.2) | 360 (4.94%) | 0.763 (1.58) | 725 (6.88%) | 1.54 (2.96) | 0.31 (0.6) | 0.216 (0.0773) | 7.05 (5.06) | 75400 (21100) | 63.6 (11.6) | 0.444 (0.088) | 0.166 (0.101) | 0.741 (0.172) | -0.24 (1.73) | 1.39 (1.3) |
North Central | 350 | 182,780 (4.08%) | 9,990 (20.9%) | 13 (14.5) | 4,490 (2.12%) | 12.8 (25.4) | 54 (0.741%) | 0.154 (0.55) | 203 (1.93%) | 0.58 (1.64) | 0.5 (0.71) | 0.227 (0.0863) | 10.5 (6.84) | 77700 (21900) | 67.9 (9.34) | 0.453 (0.0895) | 0.182 (0.1) | 0.711 (0.236) | -1.32 (0.637) | 0.582 (0.981) |
Kamloops-Salmon Arm | 204 | 133,847 (2.99%) | 2,745 (5.73%) | 24.5 (19) | 4,069 (1.92%) | 19.9 (39.5) | 89 (1.22%) | 0.436 (1.06) | 183 (1.74%) | 0.897 (2.28) | 0.18 (0.67) | 0.17 (0.0717) | 8.32 (5.27) | 71500 (20400) | 62.3 (9.95) | 0.511 (0.0944) | 0.178 (0.101) | 0.74 (0.201) | -0.714 (1.22) | 1.4 (1.47) |
Southeast | 108 | 60,427 (1.35%) | 1,599 (3.34%) | 12.8 (15.6) | 1,037 (0.489%) | 9.6 (17.9) | 24 (0.329%) | 0.222 (0.616) | 51 (0.484%) | 0.472 (1.24) | 0.079 (0.58) | 0.156 (0.0625) | 8.06 (4.35) | 68700 (16800) | 62.2 (8.54) | 0.549 (0.0921) | 0.165 (0.0835) | 0.743 (0.203) | -1.24 (0.743) | 0.321 (0.535) |
Northwest | 75 | 32,421 (0.724%) | 1,125 (2.35%) | 15.6 (22.3) | 498 (0.235%) | 6.64 (12) | 9 (0.124%) | 0.12 (0.366) | 41 (0.389%) | 0.547 (1.07) | 0.64 (0.85) | 0.239 (0.083) | 11.7 (8.09) | 74900 (16500) | 68.4 (6.63) | 0.464 (0.0953) | 0.193 (0.0932) | 0.698 (0.191) | -1.48 (0.48) | 0 (0) |
Variable | Region | Nonspatial Unadjusted IRR (95% CI)b | Spatial Unadjusted IRR (95% CI)c | Spatial Minimally Adjusted IRR (95% CI)d | Spatial Adjusted IRR (95% CI)e |
|---|---|---|---|---|---|
VanDIX (SD) | Vancouver-Squamish | 1.5 (1.42, 1.58) | 1.23 (1.15, 1.31) | 1.37 (1.3, 1.44) | 1.24 (1.19, 1.29) |
Victoria | 1.59 (1.4, 1.81) | 1.21 (1.07, 1.38) | 1.37 (1.24, 1.52) | 1.21 (1.1, 1.34) | |
Central Island-Powell River | 1.39 (1.24, 1.54) | 1.34 (1.19, 1.5) | 1.52 (1.37, 1.68) | 1.37 (1.25, 1.49) | |
Okanagan | 1.56 (1.32, 1.83) | 1.39 (1.16, 1.66) | 1.55 (1.34, 1.79) | 1.4 (1.23, 1.59) | |
Fraser Valley | 1.4 (1.22, 1.61) | 1.23 (1.05, 1.45) | 1.31 (1.16, 1.49) | 1.14 (1.02, 1.28) | |
North Central | 1.34 (1.16, 1.55) | 1.18 (1.02, 1.37) | 1.28 (1.11, 1.47) | 1.19 (1.05, 1.36) | |
Kamloops-Salmon Arm | 1.46 (1.19, 1.79) | 1.28 (1.02, 1.6) | 1.28 (1.05, 1.57) | 1.22 (1.03, 1.44) | |
Southeast | 1.65 (1.24, 2.19) | 1.44 (1.07, 1.92) | 1.48 (1.13, 1.96) | 1.44 (1.12, 1.87) | |
Northwest | 1.41 (1.12, 1.8) | 1.4 (1.11, 1.78) | 1.47 (1.18, 1.86) | 1.32 (1.07, 1.62) | |
SD = Standard Deviation; IRR = Incidence Rate Ratio; CI = Credible Interval | |||||
bFit with idd random effect at dissemination area level | |||||
cFit with idd and spatial random effect at dissemination area level | |||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | |||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | |||||
Variable | Region | Nonspatial Unadjusted IRR (95% CI)b | Spatial Unadjusted IRR (95% CI)c | Spatial Minimally Adjusted IRR (95% CI)d | Spatial Adjusted IRR (95% CI)e |
|---|---|---|---|---|---|
VanDIX (SD) | Vancouver-Squamish | 1.03 (0.966, 1.1) | 1.15 (1.07, 1.24) | 1.23 (1.16, 1.31) | 1.2 (1.12, 1.27) |
Victoria | 1.33 (1.13, 1.56) | 1.15 (0.974, 1.37) | 1.27 (1.09, 1.49) | 1.12 (0.955, 1.31) | |
Central Island-Powell River | 1.32 (1.15, 1.52) | 1.37 (1.18, 1.58) | 1.45 (1.25, 1.68) | 1.4 (1.2, 1.62) | |
Okanagan | 1.94 (1.59, 2.39) | 1.86 (1.5, 2.3) | 1.97 (1.61, 2.42) | 1.72 (1.42, 2.1) | |
Fraser Valley | 1.52 (1.26, 1.84) | 1.37 (1.1, 1.71) | 1.31 (1.05, 1.63) | 1.07 (0.863, 1.33) | |
North Central | 1.27 (1.03, 1.57) | 1.32 (1.01, 1.73) | 1.36 (1.03, 1.81) | 1.36 (1.02, 1.81) | |
Kamloops-Salmon Arm | 1.58 (1.2, 2.09) | 1.43 (1.05, 1.93) | 1.46 (1.05, 2) | 1.45 (1.02, 2.03) | |
Southeast | 1.75 (1.17, 2.61) | 1.82 (1.17, 2.91) | 2.11 (1.3, 3.47) | 2.27 (1.39, 3.74) | |
Northwest | 1.32 (0.862, 2.03) | 1.33 (0.861, 2.04) | 1.34 (0.852, 2.1) | 0.981 (0.426, 1.78) | |
SD = Standard Deviation; IRR = Incidence Rate Ratio; CI = Credible Interval | |||||
bFit with idd random effect at dissemination area level | |||||
cFit with idd and spatial random effect at dissemination area level | |||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | |||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | |||||
Variable | Region | Nonspatial Unadjusted IRR (95% CI)b | Spatial Unadjusted IRR (95% CI)c | Spatial Minimally Adjusted IRR (95% CI)d | Spatial Adjusted IRR (95% CI)e |
|---|---|---|---|---|---|
VanDIX (SD) | Vancouver-Squamish | 1.43 (1.35, 1.51) | 1.28 (1.19, 1.38) | 1.34 (1.25, 1.42) | 1.29 (1.22, 1.37) |
Victoria | 1.61 (1.37, 1.9) | 1.41 (1.19, 1.66) | 1.56 (1.33, 1.83) | 1.36 (1.16, 1.6) | |
Central Island-Powell River | 1.68 (1.45, 1.94) | 1.69 (1.45, 1.97) | 1.78 (1.53, 2.08) | 1.64 (1.42, 1.89) | |
Okanagan | 1.86 (1.53, 2.29) | 1.91 (1.53, 2.37) | 2 (1.59, 2.52) | 1.7 (1.37, 2.12) | |
Fraser Valley | 1.76 (1.5, 2.07) | 1.62 (1.35, 1.95) | 1.54 (1.29, 1.84) | 1.31 (1.11, 1.55) | |
North Central | 1.53 (1.26, 1.87) | 1.42 (1.16, 1.74) | 1.43 (1.16, 1.76) | 1.35 (1.1, 1.66) | |
Kamloops-Salmon Arm | 1.99 (1.49, 2.68) | 1.91 (1.4, 2.62) | 1.98 (1.45, 2.72) | 1.93 (1.43, 2.6) | |
Southeast | 1.85 (1.1, 3.15) | 1.7 (1.06, 2.73) | 1.77 (1.1, 2.88) | 1.79 (1.09, 2.95) | |
Northwest | 1.39 (1.14, 1.7) | 1.36 (1.02, 1.83) | 1.39 (1.04, 1.9) | 1.51 (0.853, 31.9) | |
SD = Standard Deviation; IRR = Incidence Rate Ratio; CI = Credible Interval | |||||
bFit with idd random effect at dissemination area level | |||||
cFit with idd and spatial random effect at dissemination area level | |||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | |||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | |||||
## Downloading: 7.6 kB Downloading: 7.6 kB Downloading: 12 kB Downloading: 12 kB Downloading: 12 kB Downloading: 12 kB Downloading: 20 kB Downloading: 20 kB Downloading: 40 kB Downloading: 40 kB Downloading: 40 kB Downloading: 40 kB Downloading: 44 kB Downloading: 44 kB Downloading: 44 kB Downloading: 44 kB Downloading: 44 kB Downloading: 44 kB Downloading: 68 kB Downloading: 68 kB Downloading: 72 kB Downloading: 72 kB Downloading: 97 kB Downloading: 97 kB Downloading: 97 kB Downloading: 97 kB Downloading: 150 kB Downloading: 150 kB Downloading: 150 kB Downloading: 150 kB Downloading: 200 kB Downloading: 200 kB Downloading: 200 kB Downloading: 200 kB Downloading: 220 kB Downloading: 220 kB Downloading: 240 kB Downloading: 240 kB Downloading: 240 kB Downloading: 240 kB Downloading: 240 kB Downloading: 240 kB Downloading: 240 kB Downloading: 240 kB Downloading: 280 kB Downloading: 280 kB Downloading: 280 kB Downloading: 280 kB Downloading: 280 kB Downloading: 280 kB Downloading: 280 kB Downloading: 280 kB Downloading: 370 kB Downloading: 370 kB Downloading: 430 kB Downloading: 430 kB Downloading: 430 kB Downloading: 430 kB Downloading: 430 kB Downloading: 430 kB Downloading: 430 kB Downloading: 430 kB Downloading: 450 kB Downloading: 450 kB Downloading: 450 kB Downloading: 450 kB Downloading: 480 kB Downloading: 480 kB Downloading: 500 kB Downloading: 500 kB Downloading: 500 kB Downloading: 500 kB Downloading: 530 kB Downloading: 530 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 550 kB Downloading: 740 kB Downloading: 740 kB Downloading: 740 kB Downloading: 740 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 890 kB Downloading: 910 kB Downloading: 910 kB Downloading: 910 kB Downloading: 910 kB Downloading: 910 kB Downloading: 910 kB Downloading: 930 kB Downloading: 930 kB Downloading: 940 kB Downloading: 940 kB Downloading: 1 MB Downloading: 1 MB Downloading: 1 MB Downloading: 1 MB Downloading: 1 MB Downloading: 1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.1 MB Downloading: 1.2 MB Downloading: 1.2 MB Downloading: 1.2 MB Downloading: 1.2 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.3 MB Downloading: 1.8 MB Downloading: 1.8 MB Downloading: 1.8 MB Downloading: 1.8 MB Downloading: 1.9 MB Downloading: 1.9 MB Downloading: 1.9 MB Downloading: 1.9 MB Downloading: 1.9 MB Downloading: 1.9 MB Downloading: 2 MB Downloading: 2 MB Downloading: 2 MB Downloading: 2 MB Downloading: 2 MB Downloading: 2 MB Downloading: 2 MB Downloading: 2 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.1 MB Downloading: 2.2 MB Downloading: 2.2 MB Downloading: 2.2 MB Downloading: 2.2 MB Downloading: 2.3 MB Downloading: 2.3 MB Downloading: 2.3 MB Downloading: 2.3 MB Downloading: 2.4 MB Downloading: 2.4 MB Downloading: 2.4 MB Downloading: 2.4 MB Downloading: 2.4 MB Downloading: 2.4 MB Downloading: 2.5 MB Downloading: 2.5 MB Downloading: 2.5 MB Downloading: 2.5 MB Downloading: 2.8 MB Downloading: 2.8 MB Downloading: 2.8 MB Downloading: 2.8 MB Downloading: 3 MB Downloading: 3 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.2 MB Downloading: 3.3 MB Downloading: 3.3 MB Downloading: 3.3 MB Downloading: 3.3 MB Downloading: 3.4 MB Downloading: 3.4 MB Downloading: 3.4 MB Downloading: 3.4 MB Downloading: 3.5 MB Downloading: 3.5 MB Downloading: 3.5 MB Downloading: 3.5 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.6 MB Downloading: 3.7 MB Downloading: 3.7 MB Downloading: 3.7 MB Downloading: 3.7 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 3.8 MB Downloading: 4 MB Downloading: 4 MB Downloading: 4 MB Downloading: 4 MB Downloading: 4.6 MB Downloading: 4.6 MB Downloading: 4.6 MB Downloading: 4.6 MB
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 2.850 (2.800, 2.900) | 2.800 (2.770, 2.840) | 3.250 (3.220, 3.280) | 2.990 (2.960, 3.020) |
vandix_z | 0.407 (0.354, 0.460) | 0.204 (0.139, 0.269) | 0.315 (0.264, 0.366) | 0.216 (0.174, 0.258) |
ln_roads_km_c | 1.290 (1.230, 1.350) | 0.987 (0.934, 1.040) | ||
roads_prop_highway_arterial_z | 0.595 (0.563, 0.626) | |||
ale_index_z | 0.111 (0.037, 0.184) | |||
canbics_index_z | 0.210 (0.137, 0.282) | |||
population_100_c | 0.017 (0.012, 0.022) | |||
Hyper Parameters | ||||
Precision for ui | 0.536 (0.508, 0.564) | 0.311 (0.285, 0.340) | 0.507 (0.469, 0.547) | 0.838 (0.766, 0.915) |
Phi for ui | 0.793 (0.749, 0.832) | 0.810 (0.777, 0.840) | 0.777 (0.732, 0.817) | |
Model Comparison Metrics | ||||
WAIC | 23973.6 | 23708.9 | 23512.6 | 23292 |
CPO | 52802.5 | 51800.4 | 49153.3 | 43649.3 |
DIC | 23972.2 | 23815 | 23704.6 | 23557.7 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -0.616 (-0.704, -0.534) | -0.522 (-0.587, -0.459) | -0.134 (-0.185, -0.083) | -0.291 (-0.352, -0.231) |
vandix_z | 0.028 (-0.035, 0.091) | 0.142 (0.069, 0.216) | 0.209 (0.146, 0.272) | 0.180 (0.118, 0.243) |
ln_roads_km_c | 1.070 (1.000, 1.140) | 0.843 (0.766, 0.920) | ||
roads_prop_highway_arterial_z | 0.302 (0.256, 0.349) | |||
ale_index_z | 0.042 (-0.047, 0.130) | |||
canbics_index_z | 0.092 (-0.001, 0.185) | |||
population_100_c | 0.022 (0.016, 0.028) | |||
Hyper Parameters | ||||
Precision for ui | 0.632 (0.577, 0.690) | 0.567 (0.489, 0.654) | 0.621 (0.532, 0.715) | 0.820 (0.688, 0.963) |
Phi for ui | 0.633 (0.534, 0.724) | 0.934 (0.876, 0.974) | 0.871 (0.788, 0.934) | |
Model Comparison Metrics | ||||
WAIC | 12145.9 | 9983.1 | 9017.6 | 8896.7 |
CPO | 76390.8 | 66742.6 | 33974.7 | 25599.4 |
DIC | 10994.4 | 9763.2 | 9035.6 | 8931.1 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -0.020 (-0.082, 0.041) | -0.034 (-0.088, 0.019) | 0.319 (0.275, 0.363) | 0.114 (0.060, 0.168) |
vandix_z | 0.358 (0.302, 0.415) | 0.249 (0.178, 0.320) | 0.289 (0.227, 0.352) | 0.257 (0.197, 0.317) |
ln_roads_km_c | 0.995 (0.928, 1.060) | 0.715 (0.639, 0.791) | ||
roads_prop_highway_arterial_z | 0.396 (0.353, 0.440) | |||
ale_index_z | 0.232 (0.142, 0.323) | |||
canbics_index_z | 0.041 (-0.051, 0.134) | |||
population_100_c | 0.027 (0.021, 0.034) | |||
Hyper Parameters | ||||
Precision for ui | 0.716 (0.659, 0.776) | 0.493 (0.428, 0.564) | 0.448 (0.395, 0.503) | 0.707 (0.598, 0.827) |
Phi for ui | 0.666 (0.576, 0.748) | 0.951 (0.908, 0.979) | 0.853 (0.767, 0.918) | |
Model Comparison Metrics | ||||
WAIC | 13203.4 | 12268.6 | 11152.8 | 10986.4 |
CPO | 74043.9 | 67190.3 | 57062.8 | 40133.7 |
DIC | 12538.9 | 11937.3 | 11177.2 | 11048.3 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 2.450 (2.340, 2.560) | 2.350 (2.280, 2.420) | 2.370 (2.320, 2.420) | 2.530 (2.440, 2.620) |
vandix_z | 0.464 (0.334, 0.595) | 0.191 (0.064, 0.320) | 0.315 (0.212, 0.419) | 0.193 (0.095, 0.291) |
ln_roads_km_c | 1.220 (1.080, 1.370) | 0.992 (0.835, 1.150) | ||
roads_prop_highway_arterial_z | 0.468 (0.373, 0.564) | |||
ale_index_z | 0.433 (0.105, 0.761) | |||
canbics_index_z | 0.370 (0.064, 0.676) | |||
population_100_c | 0.014 (-0.002, 0.031) | |||
Hyper Parameters | ||||
Precision for ui | 0.698 (0.607, 0.798) | 0.472 (0.373, 0.582) | 0.606 (0.516, 0.704) | 0.816 (0.650, 0.992) |
Phi for ui | 0.861 (0.727, 0.950) | 0.982 (0.934, 0.999) | 0.943 (0.833, 0.992) | |
Model Comparison Metrics | ||||
WAIC | 3540 | 3443 | 3336.3 | 3339.9 |
CPO | 9258.9 | 8800.7 | 7638.8 | 7087.3 |
DIC | 3529.6 | 3472.6 | 3403.1 | 3399.4 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -0.089 (-0.252, 0.065) | -0.132 (-0.274, 0.003) | -0.133 (-0.263, -0.007) | 0.053 (-0.106, 0.207) |
vandix_z | 0.283 (0.123, 0.445) | 0.142 (-0.026, 0.311) | 0.239 (0.082, 0.396) | 0.111 (-0.046, 0.269) |
ln_roads_km_c | 1.090 (0.866, 1.320) | 0.882 (0.629, 1.130) | ||
roads_prop_highway_arterial_z | 0.309 (0.167, 0.452) | |||
ale_index_z | 0.400 (-0.033, 0.835) | |||
canbics_index_z | 0.604 (0.187, 1.020) | |||
population_100_c | 0.030 (0.004, 0.058) | |||
Hyper Parameters | ||||
Precision for ui | 0.719 (0.577, 0.884) | 0.663 (0.495, 0.867) | 0.635 (0.465, 0.835) | 0.845 (0.598, 1.150) |
Phi for ui | 0.625 (0.414, 0.808) | 0.901 (0.740, 0.983) | 0.821 (0.601, 0.955) | |
Model Comparison Metrics | ||||
WAIC | 1886.3 | 1758.5 | 1685.8 | 1680.3 |
CPO | 11150.4 | 11027.6 | 11392.9 | 9794.9 |
DIC | 1844.3 | 1756.8 | 1693.8 | 1686.2 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -0.400 (-0.576, -0.235) | -0.428 (-0.578, -0.284) | -0.417 (-0.560, -0.279) | -0.297 (-0.477, -0.125) |
vandix_z | 0.476 (0.314, 0.641) | 0.343 (0.177, 0.509) | 0.442 (0.282, 0.602) | 0.311 (0.150, 0.471) |
ln_roads_km_c | 0.847 (0.617, 1.080) | 0.571 (0.306, 0.837) | ||
roads_prop_highway_arterial_z | 0.386 (0.232, 0.542) | |||
ale_index_z | 0.543 (0.083, 1.010) | |||
canbics_index_z | 0.343 (-0.120, 0.802) | |||
population_100_c | 0.036 (0.009, 0.064) | |||
Hyper Parameters | ||||
Precision for ui | 0.778 (0.608, 0.981) | 0.609 (0.437, 0.821) | 0.587 (0.433, 0.775) | 0.724 (0.515, 0.981) |
Phi for ui | 0.794 (0.571, 0.939) | 0.951 (0.828, 0.996) | 0.924 (0.745, 0.993) | |
Model Comparison Metrics | ||||
WAIC | 1578.2 | 1477.1 | 1430 | 1418.9 |
CPO | 10705.2 | 11593.9 | 10116.4 | 9015.4 |
DIC | 1562.2 | 1480.5 | 1439.7 | 1426.6 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 1.970 (1.850, 2.080) | 1.980 (1.880, 2.080) | 1.440 (1.320, 1.560) | 2.110 (1.880, 2.340) |
vandix_z | 0.326 (0.218, 0.434) | 0.290 (0.173, 0.407) | 0.418 (0.315, 0.521) | 0.313 (0.225, 0.402) |
ln_roads_km_c | 0.971 (0.835, 1.110) | 0.619 (0.476, 0.763) | ||
roads_prop_highway_arterial_z | 0.662 (0.569, 0.755) | |||
ale_index_z | 1.430 (0.957, 1.910) | |||
canbics_index_z | -0.657 (-1.110, -0.211) | |||
population_100_c | 0.063 (0.037, 0.089) | |||
Hyper Parameters | ||||
Precision for ui | 0.633 (0.550, 0.723) | 0.474 (0.357, 0.622) | 0.484 (0.377, 0.615) | 0.768 (0.596, 0.973) |
Phi for ui | 0.478 (0.271, 0.684) | 0.684 (0.544, 0.801) | 0.648 (0.503, 0.775) | |
Model Comparison Metrics | ||||
WAIC | 3560.3 | 3543.6 | 3444.1 | 3391.5 |
CPO | 10011.6 | 9920.9 | 9543.7 | 9167.3 |
DIC | 3525.7 | 3515.8 | 3456.6 | 3426.2 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.390 (-1.630, -1.180) | -1.400 (-1.620, -1.190) | -1.680 (-1.960, -1.420) | -1.050 (-1.460, -0.651) |
vandix_z | 0.280 (0.139, 0.421) | 0.314 (0.169, 0.459) | 0.374 (0.227, 0.521) | 0.334 (0.186, 0.482) |
ln_roads_km_c | 0.475 (0.249, 0.705) | 0.277 (0.008, 0.548) | ||
roads_prop_highway_arterial_z | 0.426 (0.267, 0.587) | |||
ale_index_z | 1.180 (0.385, 1.990) | |||
canbics_index_z | -0.239 (-0.959, 0.475) | |||
population_100_c | 0.056 (0.010, 0.103) | |||
Hyper Parameters | ||||
Precision for ui | 1.190 (0.806, 1.730) | 1.080 (0.689, 1.640) | 0.948 (0.574, 1.500) | 1.220 (0.719, 1.970) |
Phi for ui | 0.311 (0.080, 0.624) | 0.532 (0.229, 0.812) | 0.466 (0.174, 0.765) | |
Model Comparison Metrics | ||||
WAIC | 1013.3 | 1004.5 | 991 | 968.8 |
CPO | 11028.9 | 10258.4 | 10650.8 | 9047.9 |
DIC | 1019 | 1008.2 | 991.7 | 968.3 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.240 (-1.500, -1.010) | -1.210 (-1.450, -0.999) | -1.540 (-1.820, -1.280) | -0.644 (-1.060, -0.249) |
vandix_z | 0.517 (0.372, 0.665) | 0.524 (0.375, 0.676) | 0.578 (0.425, 0.733) | 0.494 (0.349, 0.639) |
ln_roads_km_c | 0.614 (0.361, 0.870) | 0.308 (0.037, 0.581) | ||
roads_prop_highway_arterial_z | 0.549 (0.391, 0.710) | |||
ale_index_z | 2.410 (1.650, 3.180) | |||
canbics_index_z | -1.070 (-1.760, -0.387) | |||
population_100_c | 0.112 (0.068, 0.157) | |||
Hyper Parameters | ||||
Precision for ui | 0.631 (0.483, 0.810) | 0.607 (0.441, 0.831) | 0.470 (0.302, 0.709) | 0.765 (0.504, 1.140) |
Phi for ui | 0.206 (0.032, 0.502) | 0.578 (0.281, 0.827) | 0.423 (0.150, 0.718) | |
Model Comparison Metrics | ||||
WAIC | 1400.2 | 1371.9 | 1324.3 | 1262.5 |
CPO | 11797.9 | 12231.5 | 18441.3 | 13155.7 |
DIC | 1367.1 | 1351.3 | 1312.3 | 1262.7 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 2.180 (2.030, 2.320) | 2.180 (2.090, 2.270) | 1.600 (1.490, 1.700) | 1.990 (1.820, 2.150) |
vandix_z | 0.442 (0.279, 0.607) | 0.329 (0.151, 0.507) | 0.438 (0.294, 0.582) | 0.336 (0.210, 0.462) |
ln_roads_km_c | 1.140 (0.993, 1.280) | 0.949 (0.800, 1.100) | ||
roads_prop_highway_arterial_z | 0.599 (0.492, 0.706) | |||
ale_index_z | 0.536 (0.020, 1.050) | |||
canbics_index_z | 0.032 (-0.390, 0.454) | |||
population_100_c | 0.030 (0.014, 0.047) | |||
Hyper Parameters | ||||
Precision for ui | 0.471 (0.402, 0.546) | 0.240 (0.175, 0.320) | 0.243 (0.200, 0.287) | 0.341 (0.271, 0.415) |
Phi for ui | 0.842 (0.705, 0.932) | 0.985 (0.949, 0.999) | 0.979 (0.927, 0.998) | |
Model Comparison Metrics | ||||
WAIC | 2859.1 | 2779.9 | 2649.6 | 2639.8 |
CPO | 7400.5 | 7268.9 | 6683.9 | 6352.8 |
DIC | 2820.1 | 2778 | 2701.5 | 2692.2 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.110 (-1.390, -0.857) | -1.100 (-1.330, -0.893) | -1.490 (-1.770, -1.220) | -0.989 (-1.320, -0.673) |
vandix_z | 0.665 (0.467, 0.870) | 0.618 (0.408, 0.832) | 0.676 (0.474, 0.882) | 0.545 (0.351, 0.741) |
ln_roads_km_c | 0.711 (0.474, 0.951) | 0.612 (0.344, 0.882) | ||
roads_prop_highway_arterial_z | 0.396 (0.222, 0.570) | |||
ale_index_z | 0.730 (-0.014, 1.480) | |||
canbics_index_z | 0.361 (-0.214, 0.934) | |||
population_100_c | 0.036 (0.008, 0.065) | |||
Hyper Parameters | ||||
Precision for ui | 0.591 (0.440, 0.776) | 0.416 (0.263, 0.617) | 0.333 (0.228, 0.465) | 0.424 (0.286, 0.601) |
Phi for ui | 0.799 (0.582, 0.937) | 0.954 (0.847, 0.995) | 0.962 (0.862, 0.997) | |
Model Comparison Metrics | ||||
WAIC | 1142.8 | 993.4 | 957.6 | 945.7 |
CPO | 9192.8 | 11257.1 | 11818 | 9456.2 |
DIC | 1108 | 994.9 | 964.4 | 951.8 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.060 (-1.340, -0.819) | -1.030 (-1.270, -0.813) | -1.430 (-1.710, -1.160) | -0.836 (-1.160, -0.530) |
vandix_z | 0.623 (0.423, 0.827) | 0.645 (0.428, 0.861) | 0.693 (0.462, 0.925) | 0.532 (0.314, 0.750) |
ln_roads_km_c | 0.803 (0.537, 1.070) | 0.634 (0.339, 0.930) | ||
roads_prop_highway_arterial_z | 0.574 (0.403, 0.748) | |||
ale_index_z | 1.330 (0.565, 2.100) | |||
canbics_index_z | -0.240 (-0.875, 0.390) | |||
population_100_c | 0.049 (0.018, 0.080) | |||
Hyper Parameters | ||||
Precision for ui | 0.554 (0.421, 0.712) | 0.515 (0.365, 0.710) | 0.357 (0.224, 0.536) | 0.494 (0.299, 0.767) |
Phi for ui | 0.346 (0.133, 0.610) | 0.770 (0.518, 0.932) | 0.722 (0.422, 0.920) | |
Model Comparison Metrics | ||||
WAIC | 1197.1 | 1131.6 | 1069.3 | 1034.4 |
CPO | 9296.5 | 9648.6 | 13388.4 | 11549.8 |
DIC | 1152 | 1113.5 | 1069.2 | 1039.4 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 2.470 (2.330, 2.600) | 2.480 (2.410, 2.560) | 2.270 (2.190, 2.350) | 2.720 (2.610, 2.840) |
vandix_z | 0.335 (0.195, 0.476) | 0.210 (0.047, 0.373) | 0.273 (0.145, 0.400) | 0.132 (0.017, 0.247) |
ln_roads_km_c | 1.110 (0.973, 1.240) | 0.863 (0.722, 1.000) | ||
roads_prop_highway_arterial_z | 0.581 (0.466, 0.697) | |||
ale_index_z | 0.249 (0.001, 0.498) | |||
canbics_index_z | 0.181 (-0.099, 0.456) | |||
population_100_c | 0.026 (0.002, 0.051) | |||
Hyper Parameters | ||||
Precision for ui | 0.604 (0.520, 0.696) | 0.282 (0.243, 0.325) | 0.708 (0.583, 0.852) | 0.951 (0.758, 1.170) |
Phi for ui | 1.000 (1.000, 1.000) | 0.804 (0.683, 0.894) | 0.806 (0.657, 0.914) | |
Model Comparison Metrics | ||||
WAIC | 3030.9 | 2957.1 | 2950.4 | 2931.1 |
CPO | 7254.7 | 8745.1 | 6611.3 | 6177.7 |
DIC | 3035.4 | 2989.2 | 2985.1 | 2973.4 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.270 (-1.550, -1.010) | -1.210 (-1.470, -0.976) | -1.350 (-1.600, -1.120) | -0.785 (-1.080, -0.508) |
vandix_z | 0.419 (0.231, 0.609) | 0.316 (0.094, 0.535) | 0.267 (0.047, 0.487) | 0.070 (-0.147, 0.284) |
ln_roads_km_c | 0.756 (0.509, 1.010) | 0.468 (0.208, 0.732) | ||
roads_prop_highway_arterial_z | 0.603 (0.406, 0.802) | |||
ale_index_z | 0.698 (0.279, 1.120) | |||
canbics_index_z | 0.092 (-0.495, 0.678) | |||
population_100_c | 0.046 (0.001, 0.091) | |||
Hyper Parameters | ||||
Precision for ui | 0.707 (0.515, 0.949) | 0.672 (0.481, 0.921) | 0.617 (0.423, 0.865) | 0.893 (0.585, 1.310) |
Phi for ui | 0.326 (0.108, 0.600) | 0.758 (0.486, 0.937) | 0.615 (0.283, 0.883) | |
Model Comparison Metrics | ||||
WAIC | 1022.8 | 1004.1 | 964.8 | 942.3 |
CPO | 8967.5 | 12422.2 | 18263 | 13200.9 |
DIC | 1013.4 | 998.1 | 960.7 | 941.6 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -0.600 (-0.807, -0.406) | -0.577 (-0.770, -0.395) | -0.723 (-0.906, -0.545) | -0.205 (-0.431, 0.014) |
vandix_z | 0.566 (0.408, 0.727) | 0.485 (0.302, 0.669) | 0.431 (0.255, 0.608) | 0.270 (0.102, 0.438) |
ln_roads_km_c | 0.815 (0.610, 1.020) | 0.422 (0.199, 0.646) | ||
roads_prop_highway_arterial_z | 0.622 (0.461, 0.784) | |||
ale_index_z | 0.494 (0.146, 0.842) | |||
canbics_index_z | 0.021 (-0.449, 0.489) | |||
population_100_c | 0.059 (0.022, 0.097) | |||
Hyper Parameters | ||||
Precision for ui | 0.781 (0.605, 0.992) | 0.733 (0.552, 0.956) | 0.654 (0.473, 0.873) | 1.040 (0.730, 1.440) |
Phi for ui | 0.381 (0.174, 0.617) | 0.856 (0.646, 0.971) | 0.678 (0.395, 0.893) | |
Model Comparison Metrics | ||||
WAIC | 1389.4 | 1354.3 | 1294.1 | 1265 |
CPO | 8725.1 | 10940.6 | 13480.6 | 10571.3 |
DIC | 1374.3 | 1347.5 | 1296.1 | 1271.8 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 1.390 (1.190, 1.580) | 1.440 (1.280, 1.600) | 0.699 (0.433, 0.960) | 1.200 (0.754, 1.630) |
vandix_z | 0.294 (0.153, 0.436) | 0.166 (0.021, 0.312) | 0.246 (0.108, 0.385) | 0.177 (0.048, 0.306) |
ln_roads_km_c | 0.656 (0.474, 0.839) | 0.497 (0.321, 0.672) | ||
roads_prop_highway_arterial_z | 0.631 (0.463, 0.800) | |||
ale_index_z | -0.204 (-0.780, 0.375) | |||
canbics_index_z | 0.429 (-0.183, 1.040) | |||
population_100_c | 0.034 (-0.007, 0.077) | |||
Hyper Parameters | ||||
Precision for ui | 0.537 (0.440, 0.645) | 0.308 (0.224, 0.412) | 0.236 (0.175, 0.304) | 0.276 (0.208, 0.354) |
Phi for ui | 0.774 (0.624, 0.886) | 0.943 (0.856, 0.987) | 0.955 (0.876, 0.992) | |
Model Comparison Metrics | ||||
WAIC | 1926.7 | 1859.1 | 1793.4 | 1779.7 |
CPO | 6163.4 | 8900.7 | 14150.6 | 12615.4 |
DIC | 1877.8 | 1836.9 | 1798.5 | 1791.4 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -2.100 (-2.450, -1.750) | -3.070 (-3.830, -2.440) | -3.240 (-4.090, -2.500) | -2.310 (-3.320, -1.370) |
vandix_z | 0.238 (0.027, 0.450) | 0.276 (0.011, 0.547) | 0.307 (0.029, 0.591) | 0.304 (0.022, 0.593) |
ln_roads_km_c | 0.127 (-0.188, 0.449) | 0.171 (-0.174, 0.521) | ||
roads_prop_highway_arterial_z | 0.522 (0.141, 0.908) | |||
ale_index_z | -0.216 (-1.610, 1.180) | |||
canbics_index_z | 1.980 (0.896, 3.090) | |||
population_100_c | -0.072 (-0.230, 0.085) | |||
Hyper Parameters | ||||
Precision for ui | 19,900.000 (586.000, 73,900.000) | 0.660 (0.352, 1.150) | 0.647 (0.344, 1.130) | 0.890 (0.417, 1.730) |
Phi for ui | 0.162 (0.024, 0.449) | 0.195 (0.031, 0.516) | 0.288 (0.055, 0.663) | |
Model Comparison Metrics | ||||
WAIC | 343.9 | 281.6 | 281.4 | 280.1 |
CPO | 172 | 216697.9 | 216794.6 | 180273 |
DIC | 342.5 | 276.9 | 276.5 | 272.4 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.970 (-2.450, -1.570) | -1.860 (-2.270, -1.500) | -1.940 (-2.440, -1.490) | -1.890 (-2.800, -1.050) |
vandix_z | 0.424 (0.227, 0.627) | 0.350 (0.148, 0.553) | 0.355 (0.150, 0.563) | 0.301 (0.096, 0.509) |
ln_roads_km_c | 0.071 (-0.195, 0.358) | -0.097 (-0.402, 0.228) | ||
roads_prop_highway_arterial_z | 0.659 (0.375, 0.946) | |||
ale_index_z | -1.050 (-2.310, 0.173) | |||
canbics_index_z | 0.649 (-0.317, 1.630) | |||
population_100_c | 0.018 (-0.069, 0.105) | |||
Hyper Parameters | ||||
Precision for ui | 0.563 (0.378, 0.802) | 0.555 (0.349, 0.847) | 0.531 (0.317, 0.843) | 0.546 (0.303, 0.909) |
Phi for ui | 0.357 (0.102, 0.683) | 0.415 (0.107, 0.778) | 0.528 (0.170, 0.865) | |
Model Comparison Metrics | ||||
WAIC | 627.3 | 592 | 590.7 | 578.1 |
CPO | 6798.8 | 17702.3 | 19683.2 | 22481.3 |
DIC | 613.6 | 589.8 | 588.2 | 575.5 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 1.940 (1.730, 2.140) | 1.950 (1.790, 2.110) | 1.430 (1.230, 1.630) | 1.130 (0.900, 1.370) |
vandix_z | 0.379 (0.178, 0.581) | 0.244 (0.019, 0.469) | 0.249 (0.047, 0.451) | 0.199 (0.034, 0.365) |
ln_roads_km_c | 0.850 (0.643, 1.060) | 0.492 (0.303, 0.682) | ||
roads_prop_highway_arterial_z | 0.535 (0.425, 0.646) | |||
ale_index_z | 0.092 (-0.412, 0.596) | |||
canbics_index_z | -0.709 (-1.200, -0.220) | |||
population_100_c | 0.099 (0.062, 0.135) | |||
Hyper Parameters | ||||
Precision for ui | 0.565 (0.441, 0.708) | 0.646 (0.497, 0.824) | 0.773 (0.588, 0.996) | 1.170 (0.867, 1.530) |
Phi for ui | 0.421 (0.223, 0.639) | 0.627 (0.427, 0.804) | 0.820 (0.622, 0.948) | |
Model Comparison Metrics | ||||
WAIC | 1199 | 1181.7 | 1151.7 | 1123.5 |
CPO | 3437.7 | 3381 | 4627 | 4126.6 |
DIC | 1187.1 | 1176.1 | 1158.3 | 1138.2 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.700 (-2.220, -1.270) | -1.620 (-2.050, -1.230) | -2.040 (-2.620, -1.520) | -1.920 (-2.590, -1.310) |
vandix_z | 0.456 (0.182, 0.737) | 0.358 (0.051, 0.655) | 0.376 (0.053, 0.691) | 0.372 (0.017, 0.706) |
ln_roads_km_c | 0.585 (0.198, 0.991) | 0.195 (-0.225, 0.626) | ||
roads_prop_highway_arterial_z | 0.399 (0.130, 0.673) | |||
ale_index_z | 0.639 (-0.333, 1.590) | |||
canbics_index_z | -0.277 (-1.240, 0.693) | |||
population_100_c | 0.141 (0.066, 0.217) | |||
Hyper Parameters | ||||
Precision for ui | 0.921 (0.468, 1.710) | 1.050 (0.560, 1.840) | 1.050 (0.546, 1.880) | 1.810 (0.713, 4.030) |
Phi for ui | 0.214 (0.035, 0.531) | 0.523 (0.162, 0.874) | 0.627 (0.180, 0.950) | |
Model Comparison Metrics | ||||
WAIC | 326.1 | 325.4 | 318.6 | 311.1 |
CPO | 3803.5 | 8353.3 | 15976.5 | 10699.7 |
DIC | 325 | 323.3 | 316.7 | 308.2 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.600 (-2.130, -1.160) | -1.460 (-1.890, -1.090) | -1.850 (-2.350, -1.390) | -1.580 (-2.170, -1.030) |
vandix_z | 0.687 (0.402, 0.988) | 0.649 (0.340, 0.964) | 0.685 (0.371, 1.000) | 0.659 (0.359, 0.957) |
ln_roads_km_c | 0.619 (0.267, 0.979) | 0.245 (-0.124, 0.619) | ||
roads_prop_highway_arterial_z | 0.393 (0.152, 0.636) | |||
ale_index_z | 1.570 (0.680, 2.450) | |||
canbics_index_z | -0.979 (-1.880, -0.099) | |||
population_100_c | 0.111 (0.039, 0.184) | |||
Hyper Parameters | ||||
Precision for ui | 0.506 (0.316, 0.761) | 0.625 (0.404, 0.923) | 0.674 (0.425, 1.020) | 1.080 (0.602, 1.830) |
Phi for ui | 0.271 (0.077, 0.552) | 0.478 (0.194, 0.781) | 0.379 (0.067, 0.786) | |
Model Comparison Metrics | ||||
WAIC | 439.8 | 423.7 | 414.9 | 404.6 |
CPO | 12443.2 | 15490.7 | 16687.5 | 10292.4 |
DIC | 421.6 | 415.6 | 408.9 | 400.8 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 1.310 (1.040, 1.570) | 1.320 (1.100, 1.530) | 0.761 (0.435, 1.080) | 1.750 (0.950, 2.540) |
vandix_z | 0.500 (0.219, 0.783) | 0.363 (0.072, 0.653) | 0.394 (0.121, 0.670) | 0.367 (0.112, 0.626) |
ln_roads_km_c | 0.707 (0.396, 1.020) | 0.450 (0.093, 0.813) | ||
roads_prop_highway_arterial_z | 0.570 (0.271, 0.868) | |||
ale_index_z | 1.650 (0.043, 3.270) | |||
canbics_index_z | -0.567 (-2.250, 1.110) | |||
population_100_c | 0.143 (0.028, 0.260) | |||
Hyper Parameters | ||||
Precision for ui | 0.708 (0.490, 0.976) | 0.778 (0.549, 1.070) | 0.855 (0.593, 1.190) | 1.030 (0.708, 1.440) |
Phi for ui | 0.387 (0.138, 0.690) | 0.643 (0.326, 0.897) | 0.679 (0.367, 0.912) | |
Model Comparison Metrics | ||||
WAIC | 548.8 | 543.7 | 527.6 | 521.5 |
CPO | 1996.6 | 1958.9 | 2617.1 | 2620.3 |
DIC | 544.6 | 540.4 | 530.5 | 526.6 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.760 (-2.240, -1.280) | -1.980 (-2.770, -1.370) | -2.420 (-3.340, -1.610) | -0.837 (-2.050, 0.351) |
vandix_z | 0.560 (0.161, 0.959) | 0.601 (0.158, 1.070) | 0.748 (0.264, 1.240) | 0.822 (0.331, 1.320) |
ln_roads_km_c | 0.444 (-0.034, 0.926) | 0.197 (-0.536, 0.930) | ||
roads_prop_highway_arterial_z | 0.315 (-0.335, 0.970) | |||
ale_index_z | 1.870 (-0.795, 4.570) | |||
canbics_index_z | 0.194 (-2.360, 2.750) | |||
population_100_c | 0.276 (0.090, 0.464) | |||
Hyper Parameters | ||||
Precision for ui | 20,000.000 (615.000, 74,000.000) | 12.700 (0.779, 78.100) | 56.500 (0.765, 383.000) | 8,350.000 (0.919, 28,600.000) |
Phi for ui | 0.293 (0.018, 0.826) | 0.361 (0.028, 0.881) | 0.356 (0.019, 0.906) | |
Model Comparison Metrics | ||||
WAIC | 130.7 | 132.3 | 128.1 | 124.6 |
CPO | 65.4 | 35855.1 | 9993.4 | 8971.5 |
DIC | 130.2 | 124.3 | 123.6 | 120.5 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -2.130 (-3.140, -1.400) | -1.840 (-2.530, -1.260) | -2.060 (-2.850, -1.360) | -1.260 (-2.890, 0.272) |
vandix_z | 0.616 (0.093, 1.150) | 0.529 (0.060, 1.000) | 0.574 (0.091, 1.060) | 0.581 (0.085, 1.080) |
ln_roads_km_c | 0.267 (-0.242, 0.779) | -0.061 (-0.829, 0.693) | ||
roads_prop_highway_arterial_z | 0.297 (-0.359, 0.948) | |||
ale_index_z | 0.576 (-2.260, 3.370) | |||
canbics_index_z | 0.058 (-2.830, 3.030) | |||
population_100_c | 0.213 (-0.015, 0.448) | |||
Hyper Parameters | ||||
Precision for ui | 0.529 (0.233, 1.030) | 0.734 (0.370, 1.330) | 0.753 (0.372, 1.380) | 0.728 (0.346, 1.380) |
Phi for ui | 0.176 (0.012, 0.565) | 0.214 (0.016, 0.647) | 0.241 (0.019, 0.695) | |
Model Comparison Metrics | ||||
WAIC | 191.5 | 170.6 | 172.5 | 177.6 |
CPO | 59059.2 | 46976 | 49599.3 | 56251 |
DIC | 170.5 | 167.2 | 168.3 | 169.9 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | 0.693 (0.252, 1.100) | 0.728 (0.321, 1.110) | 0.308 (-0.125, 0.719) | -4.530 (-24.600, 13.800) |
vandix_z | 0.344 (0.109, 0.586) | 0.338 (0.106, 0.574) | 0.388 (0.162, 0.621) | 0.274 (0.066, 0.483) |
ln_roads_km_c | 0.688 (0.354, 1.020) | 0.376 (-0.166, 0.939) | ||
roads_prop_highway_arterial_z | 0.241 (-0.183, 0.665) | |||
ale_index_z | 3.280 (1.540, 5.020) | |||
canbics_index_z | -8.760 (-30.000, 14.600) | |||
population_100_c | 0.406 (0.172, 0.641) | |||
Hyper Parameters | ||||
Precision for ui | 0.694 (0.428, 1.050) | 0.759 (0.480, 1.150) | 0.678 (0.375, 1.120) | 1.250 (0.766, 1.910) |
Phi for ui | 0.162 (0.004, 0.611) | 0.651 (0.195, 0.957) | 0.121 (0.003, 0.553) | |
Model Comparison Metrics | ||||
WAIC | 352.2 | 355.4 | 339.4 | 237747.2 |
CPO | 1402.9 | 1420 | 2089.3 | 25154.2 |
DIC | 347 | 349 | 338.6 | -1346432140868630016 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -2.580 (-3.520, -1.640) | -2.610 (-3.560, -1.660) | -2.660 (-3.720, -1.600) | -38.500 (-110.000, 13.700) |
vandix_z | 0.279 (-0.149, 0.707) | 0.282 (-0.150, 0.715) | 0.291 (-0.160, 0.743) | -0.019 (-0.853, 0.574) |
ln_roads_km_c | -0.058 (-0.757, 0.642) | -1.660 (-5.450, 0.494) | ||
roads_prop_highway_arterial_z | 0.788 (-0.620, 2.190) | |||
ale_index_z | 3.290 (-4.600, 10.000) | |||
canbics_index_z | -45.600 (-129.000, 14.800) | |||
population_100_c | 0.804 (-0.032, 2.160) | |||
Hyper Parameters | ||||
Precision for ui | 20,000.000 (628.000, 74,000.000) | 1,260.000 (2.360, 7,910.000) | 1,280.000 (2.320, 8,000.000) | 1,380.000 (2.380, 8,520.000) |
Phi for ui | 0.341 (0.009, 0.927) | 0.340 (0.009, 0.927) | 0.341 (0.009, 0.927) | |
Model Comparison Metrics | ||||
WAIC | 60 | 59.9 | 62 | 708.6 |
CPO | 44.2 | 114.8 | 232.2 | 4751.9 |
DIC | 59.8 | 59.7 | 61.6 | 102.8 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
term | Nonspatialb | Unadjustedc | Adjusted1d | Adjusted2e |
|---|---|---|---|---|
Fixed Effects | ||||
(Intercept) | -1.050 (-1.500, -0.606) | -1.430 (-2.170, -0.810) | -1.610 (-2.460, -0.890) | -19.300 (-99.200, 14.700) |
vandix_z | 0.330 (0.132, 0.528) | 0.309 (0.023, 0.605) | 0.333 (0.035, 0.642) | 0.413 (-0.160, 3.460) |
ln_roads_km_c | 0.207 (-0.242, 0.680) | -0.580 (-9.530, 0.999) | ||
roads_prop_highway_arterial_z | 0.788 (-0.446, 7.200) | |||
ale_index_z | 6.220 (1.130, 32.900) | |||
canbics_index_z | -20.300 (-101.000, 14.300) | |||
population_100_c | 0.324 (-1.860, 2.080) | |||
Hyper Parameters | ||||
Precision for ui | 19,900.000 (594.000, 73,900.000) | 1.770 (0.557, 4.670) | 1.580 (0.507, 4.110) | 2.400 (0.625, 7.230) |
Phi for ui | 0.303 (0.021, 0.817) | 0.387 (0.033, 0.890) | 0.285 (0.019, 0.794) | |
Model Comparison Metrics | ||||
WAIC | 164.6 | 145.8 | 144.6 | 38338.2 |
CPO | 83.7 | 2010.5 | 2692.3 | 5511.2 |
DIC | 162.7 | 140.7 | 139.9 | -6.58997031579091e+24 |
bFit with idd random effect at dissemination area level | ||||
cFit with idd and spatial random effect at dissemination area level | ||||
dFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads | ||||
eFit with idd and spatial random effect at dissemination area level + adjusted for (i) total length of roads; (ii) proportion of roads classified as highway or arterial; (iii) the Canadian Active Living Environment Index; (iv) the Canadian Bikeway Comfort and Safety Index; (v) total population | ||||
## [1] "Total run time: 26.3 minutes"
## [1] "2024-10-11 12:15:20 PDT"
## Local: main C:/Users/micha/Documents/GitHub/Area-Level-Deprivation-Traffic-Injury
## Remote: main @ origin (https://github.com/mbcalles/Area-Level-Deprivation-Traffic-Injury.git)
## Head: [29024e1] 2024-10-08: Remove old scripts
## R version 4.4.1 (2024-06-14 ucrt)
## Platform: x86_64-w64-mingw32/x64
## Running under: Windows 11 x64 (build 22631)
##
## Matrix products: default
##
##
## locale:
## [1] LC_COLLATE=English_Canada.utf8 LC_CTYPE=English_Canada.utf8
## [3] LC_MONETARY=English_Canada.utf8 LC_NUMERIC=C
## [5] LC_TIME=English_Canada.utf8
##
## time zone: America/Vancouver
## tzcode source: internal
##
## attached base packages:
## [1] stats graphics grDevices utils datasets methods base
##
## other attached packages:
## [1] extrafont_0.19 broom_1.0.7 janitor_2.2.0 cowplot_1.1.3
## [5] rcartocolor_2.1.1 RColorBrewer_1.1-3 flextable_0.9.6 spdep_1.3-6
## [9] sf_1.0-17 spData_2.3.3 lubridate_1.9.3 forcats_1.0.0
## [13] stringr_1.5.1 dplyr_1.1.4 purrr_1.0.2 readr_2.1.5
## [17] tidyr_1.3.1 tibble_3.2.1 ggplot2_3.5.1 tidyverse_2.0.0
## [21] INLA_24.06.27 sp_2.1-4 Matrix_1.7-0
##
## loaded via a namespace (and not attached):
## [1] DBI_1.2.3 deldir_2.0-4 s2_1.1.7
## [4] rlang_1.1.4 magrittr_2.0.3 git2r_0.33.0
## [7] hrbrthemes_0.8.7 snakecase_0.11.1 e1071_1.7-16
## [10] compiler_4.4.1 mgcv_1.9-1 systemfonts_1.1.0
## [13] vctrs_0.6.5 pkgconfig_2.0.3 wk_0.9.3
## [16] crayon_1.5.3 fastmap_1.2.0 backports_1.5.0
## [19] labeling_0.4.3 geojsonsf_2.0.3 utf8_1.2.4
## [22] rmarkdown_2.28 tzdb_0.4.0 ragg_1.3.3
## [25] MatrixModels_0.5-3 bit_4.5.0 xfun_0.47
## [28] cachem_1.1.0 jsonlite_1.8.9 cancensus_0.5.7
## [31] highr_0.11 uuid_1.2-1 tictoc_1.2.1
## [34] parallel_4.4.1 R6_2.5.1 bslib_0.8.0
## [37] stringi_1.8.4 extrafontdb_1.0 boot_1.3-30
## [40] jquerylib_0.1.4 Rcpp_1.0.13 knitr_1.48
## [43] audio_0.1-11 splines_4.4.1 timechange_0.3.0
## [46] tidyselect_1.2.1 rstudioapi_0.16.0 yaml_2.3.10
## [49] curl_5.2.3 lattice_0.22-6 withr_3.0.1
## [52] askpass_1.2.0 evaluate_1.0.0 units_0.8-5
## [55] proxy_0.4-27 zip_2.3.1 xml2_1.3.6
## [58] pillar_1.9.0 KernSmooth_2.23-24 generics_0.1.3
## [61] vroom_1.6.5 hms_1.1.3 munsell_0.5.1
## [64] scales_1.3.0 class_7.3-22 glue_1.8.0
## [67] gdtools_0.4.0 tools_4.4.1 data.table_1.16.0
## [70] beepr_2.0 grid_4.4.1 Rttf2pt1_1.3.12
## [73] colorspace_2.1-1 nlme_3.1-164 ggspatial_1.1.9
## [76] cli_3.6.3 textshaping_0.4.0 officer_0.6.6
## [79] fontBitstreamVera_0.1.1 fansi_1.0.6 fmesher_0.1.7
## [82] gtable_0.3.5 sass_0.4.9 digest_0.6.37
## [85] fontquiver_0.2.1 classInt_0.4-10 ggrepel_0.9.6
## [88] farver_2.1.2 htmltools_0.5.8.1 lifecycle_1.0.4
## [91] httr_1.4.7 fontLiberation_0.1.0 openssl_2.2.2
## [94] bit64_4.5.2